remove :custom option key

This commit is contained in:
technoweenie 2012-10-21 15:05:59 -06:00
parent fa58f794c5
commit dc383b0999
2 changed files with 21 additions and 21 deletions

View File

@ -58,7 +58,7 @@ module Faraday
class RequestOptions < Options.new(:params_encoder, :proxy, :bind, class RequestOptions < Options.new(:params_encoder, :proxy, :bind,
:timeout, :open_timeout, :boundary, :timeout, :open_timeout, :boundary,
:custom, :oauth) :oauth)
def params_encoder def params_encoder
self[:params_encoder] ||= NestedParamsEncoder self[:params_encoder] ||= NestedParamsEncoder

View File

@ -6,29 +6,29 @@ class EnvTest < Faraday::TestCase
:headers => {'Mime-Version' => '1.0'}, :headers => {'Mime-Version' => '1.0'},
:request => {:oauth => {:consumer_key => 'anonymous'}} :request => {:oauth => {:consumer_key => 'anonymous'}}
@conn.options[:timeout] = 3 @conn.options.timeout = 3
@conn.options[:open_timeout] = 5 @conn.options.open_timeout = 5
@conn.ssl[:verify] = false @conn.ssl.verify = false
@conn.proxy 'http://proxy.com' @conn.proxy 'http://proxy.com'
end end
def test_request_create_stores_method def test_request_create_stores_method
env = make_env(:get) env = make_env(:get)
assert_equal :get, env[:method] assert_equal :get, env.method
end end
def test_request_create_stores_uri def test_request_create_stores_uri
env = make_env do |req| env = make_env do |req|
req.url 'foo.json', 'a' => 1 req.url 'foo.json', 'a' => 1
end end
assert_equal 'http://sushi.com/api/foo.json?a=1', env[:url].to_s assert_equal 'http://sushi.com/api/foo.json?a=1', env.url.to_s
end end
def test_request_create_stores_headers def test_request_create_stores_headers
env = make_env do |req| env = make_env do |req|
req['Server'] = 'Faraday' req['Server'] = 'Faraday'
end end
headers = env[:request_headers] headers = env.request_headers
assert_equal '1.0', headers['mime-version'] assert_equal '1.0', headers['mime-version']
assert_equal 'Faraday', headers['server'] assert_equal 'Faraday', headers['server']
end end
@ -37,37 +37,37 @@ class EnvTest < Faraday::TestCase
env = make_env do |req| env = make_env do |req|
req.body = 'hi' req.body = 'hi'
end end
assert_equal 'hi', env[:body] assert_equal 'hi', env.body
end end
def test_global_request_options def test_global_request_options
env = make_env env = make_env
assert_equal 3, env[:request][:timeout] assert_equal 3, env.request.timeout
assert_equal 5, env[:request][:open_timeout] assert_equal 5, env.request.open_timeout
end end
def test_per_request_options def test_per_request_options
env = make_env do |req| env = make_env do |req|
req.options[:timeout] = 10 req.options.timeout = 10
req.options[:custom] = true req.options.boundary = 'boo'
req.options[:oauth][:consumer_secret] = 'xyz' req.options.oauth[:consumer_secret] = 'xyz'
end end
assert_equal 10, env[:request][:timeout] assert_equal 10, env.request.timeout
assert_equal 5, env[:request][:open_timeout] assert_equal 5, env.request.open_timeout
assert_equal true, env[:request][:custom] assert_equal 'boo', env.request.boundary
oauth_expected = {:consumer_secret => 'xyz', :consumer_key => 'anonymous'} oauth_expected = {:consumer_secret => 'xyz', :consumer_key => 'anonymous'}
assert_equal oauth_expected, env[:request][:oauth] assert_equal oauth_expected, env.request.oauth
end end
def test_request_create_stores_ssl_options def test_request_create_stores_ssl_options
env = make_env env = make_env
assert_equal false, env[:ssl][:verify] assert_equal false, env.ssl.verify
end end
def test_request_create_stores_proxy_options def test_request_create_stores_proxy_options
env = make_env env = make_env
assert_equal 'proxy.com', env[:request][:proxy][:uri].host assert_equal 'proxy.com', env.request.proxy.host
end end
private private
@ -174,10 +174,10 @@ class ResponseTest < Faraday::TestCase
def test_marshal def test_marshal
@response = Faraday::Response.new @response = Faraday::Response.new
@response.on_complete { } @response.on_complete { }
@response.finish @env.merge(:custom => 'moo') @response.finish @env.merge(:params => 'moo')
loaded = Marshal.load Marshal.dump(@response) loaded = Marshal.load Marshal.dump(@response)
assert_nil loaded.env[:custom] assert_nil loaded.env[:params]
assert_equal %w[body response_headers status], loaded.env.keys.map { |k| k.to_s }.sort assert_equal %w[body response_headers status], loaded.env.keys.map { |k| k.to_s }.sort
end end
end end