test/test_client.rb in octoparts-0.0.5 vs test/test_client.rb in octoparts-0.0.6
- old
+ new
@@ -1,6 +1,7 @@
require 'helper'
+require 'active_support/core_ext/string/inflections'
class TestClient < Test::Unit::TestCase
def setup
@client = Octoparts::Client.new
end
@@ -107,26 +108,37 @@
end
end
end
sub_test_case "timeout" do
+ setup do
+ @endpoint = Octoparts.configuration.endpoint
+ Octoparts.configure do |c|
+ # avoiding connection failed error, sorry heroku...
+ # we should find other way
+ c.endpoint = 'http://octoparts.herokuapp.com'
+ end
+ @exception_class = defined?(Faraday::TimeoutError) ? Faraday::TimeoutError : Faraday::Error::TimeoutError
+ end
+
teardown do
Octoparts.configure do |c|
+ c.endpoint = @endpoint
c.timeout_sec = nil
end
end
test "timeout_sec option" do
- assert_raise Faraday::TimeoutError do
+ assert_raise @exception_class do
Octoparts::Client.new(timeout_sec: 0).get('/')
end
end
test "open_timeout_sec option" do
Octoparts.configure do |c|
c.timeout_sec = 0
end
- assert_raise Faraday::TimeoutError do
+ assert_raise @exception_class do
Octoparts::Client.new.get('/')
end
end
end
end