test/error_test.rb in tracker_api-1.9.1 vs test/error_test.rb in tracker_api-1.10.0

- old
+ new

@@ -20,11 +20,11 @@ assert_raises TrackerApi::Errors::ServerError do client.send(:request, :get, options) end end end - + it 'raises RuntimeError for HTTP status codes < 400 and > 500' do [399, 600].each do |status_code| mock_faraday_error(status_code) assert_raises RuntimeError, "Expected 4xx or 5xx HTTP status code" do client.send(:request, :get, options) @@ -33,9 +33,15 @@ end # Simulate the error Faraday will raise with a specific HTTP status code so # we can test our rescuing of those errors def mock_faraday_error(status_code) + mocked_error_class = if (500..599).include?(status_code) && Faraday::VERSION.to_f >= 16.0 + Faraday::ServerError + else + Faraday::ClientError + end + ::Faraday::Connection.any_instance.stubs(:get). - raises(::Faraday::Error::ClientError.new(nil, { status: status_code})) + raises(mocked_error_class.new(nil, { status: status_code})) end end