Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Fix error in json parsing #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*.so
*.o
*.a
.rvmrc
mkmf.log
/.idea/
*.iml
Expand Down
2 changes: 1 addition & 1 deletion lib/telegram_bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
require "telegram_bot/force_replay"
require "telegram_bot/out_message"
require "telegram_bot/update"
require "telegram_bot/api_response_error"
require "telegram_bot/api_response"
require "telegram_bot/response_error"
require "telegram_bot/bot"


Expand Down
2 changes: 1 addition & 1 deletion lib/telegram_bot/api_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(res)
@result = data["result"]
else
@ok = false
error = ResponseError.new(res)
error = ApiResponseError.new(res)
fail error, "An error has occurred: #{error.data}", caller
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module TelegramBot
class ResponseError < StandardError
class ApiResponseError < StandardError
attr_reader :response

def initialize(res)
Expand Down
7 changes: 7 additions & 0 deletions spec/api_response_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'minitest_helper'

describe TelegramBot::ApiResponse do
it 'does not raise uninitialized constant TelegramBot::ApiResponse::ResponseError' do
expect { described_class.new(double(body: "{\"error\":\"test\"}", status: 500)) }.not_to raise_error(NameError)
end
end
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'bundler/setup'
Bundler.setup

require 'telegram_bot'

RSpec.configure do |config|
# some config here if needed
end
1 change: 1 addition & 0 deletions telegram_bot.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.7"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "minitest", "~> 5.10"
spec.add_development_dependency "rspec"
end