提交 8b139444 编写于 作者: S Sean Griffin 提交者: GitHub

Merge pull request #30688 from y-yagi/make_bang_verion_work_with_inheritable_options

Make bang version work with `InheritableOptions`
......@@ -46,7 +46,7 @@ def method_missing(name, *args)
bangs = name_string.chomp!("!")
if bangs
fetch(name_string.to_sym).presence || raise(KeyError.new(":#{name_string} is blank"))
self[name_string].presence || raise(KeyError.new(":#{name_string} is blank"))
else
self[name_string]
end
......
......@@ -102,4 +102,17 @@ def test_raises_with_bang
end
assert_raises(KeyError) { a.non_existing_key! }
end
def test_inheritable_options_with_bang
a = ActiveSupport::InheritableOptions.new(foo: :bar)
assert_nothing_raised { a.foo! }
assert_equal a.foo, a.foo!
assert_raises(KeyError) do
a.foo = nil
a.foo!
end
assert_raises(KeyError) { a.non_existing_key! }
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册