Options#fetch should not return the default for false or nil values.

This commit is contained in:
Ben Burkert 2013-10-16 11:45:45 -07:00
parent 212278c339
commit 7d0defae6e
No known key found for this signature in database
GPG Key ID: 7F8B7CF7590D2B35
2 changed files with 9 additions and 2 deletions

View File

@ -48,8 +48,9 @@ module Faraday
# Public
def fetch(key, default = nil)
send(key) || send("#{key}=", default ||
(block_given? ? Proc.new.call : nil))
return send(key) if keys.include?(key)
send("#{key}=", default || (block_given? ? Proc.new.call : nil))
end
# Public

View File

@ -164,4 +164,10 @@ class OptionsTest < Faraday::TestCase
e["custom"] = :boom
assert_equal :boom, e["custom"]
end
def test_env_fetch_ignores_false
ssl = Faraday::SSLOptions.new
ssl.verify = false
assert !ssl.fetch(:verify, true)
end
end