mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
Compare commits
No commits in common. "0633daaf8e0b0f7b3254a2b7f143040a3fb6327e" and "e9d5b75298c7cc65a8744d2cfbecc9cc83970376" have entirely different histories.
0633daaf8e
...
e9d5b75298
@ -342,11 +342,12 @@ module HTTPX
|
|||||||
defaults.each do |k, v|
|
defaults.each do |k, v|
|
||||||
next if v.nil?
|
next if v.nil?
|
||||||
|
|
||||||
option_method_name = :"option_#{k}"
|
begin
|
||||||
raise Error, "unknown option: #{k}" unless respond_to?(option_method_name)
|
value = __send__(:"option_#{k}", v)
|
||||||
|
instance_variable_set(:"@#{k}", value)
|
||||||
value = __send__(option_method_name, v)
|
rescue NoMethodError
|
||||||
instance_variable_set(:"@#{k}", value)
|
raise Error, "unknown option: #{k}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -10,18 +10,6 @@ class OptionsTest < Minitest::Test
|
|||||||
assert ex.message == "unknown option: foo", ex.message
|
assert ex.message == "unknown option: foo", ex.message
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_options_no_method_error_during_validation
|
|
||||||
custom_opt_class = Class.new(Options) do
|
|
||||||
def option_foo(value)
|
|
||||||
raise TypeError, ":foo must be a Hash" unless value.is_a(Hash)
|
|
||||||
|
|
||||||
value
|
|
||||||
end
|
|
||||||
end
|
|
||||||
ex = assert_raises(NoMethodError) { custom_opt_class.new(foo: "bar") }
|
|
||||||
assert_match("undefined method `is_a'", ex.message)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_options_body
|
def test_options_body
|
||||||
opt1 = Options.new
|
opt1 = Options.new
|
||||||
assert opt1.body.nil?, "body shouldn't be set by default"
|
assert opt1.body.nil?, "body shouldn't be set by default"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user