diff --git a/.gitignore b/.gitignore index 9f74d68..736ed9f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ *.so *.o *.a +.rvmrc mkmf.log /.idea/ *.iml diff --git a/lib/telegram_bot.rb b/lib/telegram_bot.rb index e731399..d4f493f 100644 --- a/lib/telegram_bot.rb +++ b/lib/telegram_bot.rb @@ -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" diff --git a/lib/telegram_bot/api_response.rb b/lib/telegram_bot/api_response.rb index f339e37..38e862a 100644 --- a/lib/telegram_bot/api_response.rb +++ b/lib/telegram_bot/api_response.rb @@ -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 diff --git a/lib/telegram_bot/response_error.rb b/lib/telegram_bot/api_response_error.rb similarity index 88% rename from lib/telegram_bot/response_error.rb rename to lib/telegram_bot/api_response_error.rb index c22133d..befb3b5 100644 --- a/lib/telegram_bot/response_error.rb +++ b/lib/telegram_bot/api_response_error.rb @@ -1,5 +1,5 @@ module TelegramBot - class ResponseError < StandardError + class ApiResponseError < StandardError attr_reader :response def initialize(res) diff --git a/spec/api_response_spec.rb b/spec/api_response_spec.rb new file mode 100644 index 0000000..2aa7136 --- /dev/null +++ b/spec/api_response_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..444e6e8 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,8 @@ +require 'bundler/setup' +Bundler.setup + +require 'telegram_bot' + +RSpec.configure do |config| + # some config here if needed +end \ No newline at end of file diff --git a/telegram_bot.gemspec b/telegram_bot.gemspec index b31277d..bb7b6ae 100644 --- a/telegram_bot.gemspec +++ b/telegram_bot.gemspec @@ -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