faraday/test/adapters/net_http_persistent_test.rb
Mattia f994b054f9 Support adapter customization (#651)
* add initializer on Faraday::Adapter that accept and store a block with custom configuration
use the `@ config_block ` block on `net_http` and `net_http_persistent` adapters
added tests

* fixes warning in tests
patron was supporting custom block already! Small refactoring to conform to other adapters

* added implementation for httpclient
excon and EM adapters now all support `connection_options` in the initializer

* additional test for httpclient adapter
2017-01-13 12:07:01 +00:00

33 lines
889 B
Ruby

require File.expand_path('../integration', __FILE__)
module Adapters
class NetHttpPersistentTest < Faraday::TestCase
def adapter() :net_http_persistent end
Integration.apply(self, :NonParallel) do
def setup
if defined?(Net::HTTP::Persistent)
# work around problems with mixed SSL certificates
# https://github.com/drbrain/net-http-persistent/issues/45
http = Net::HTTP::Persistent.new('Faraday')
http.ssl_cleanup(4)
end
end if ssl_mode?
end
def test_custom_adapter_config
url = URI('https://example.com:1234')
adapter = Faraday::Adapter::NetHttpPersistent.new do |http|
http.idle_timeout = 123
end
http = adapter.net_http_connection(:url => url, :request => {})
adapter.configure_request(http, {})
assert_equal 123, http.idle_timeout
end
end
end