提交 b99014bf 编写于 作者: A Akira Matsuda

AS::StringInquirer#respond_to_missing? should fallback to super

in case String or any other ancestor class' respond_to_missing? was defined.
上级 b89316fe
* Fixed a bug that `ArrayInquirer#respond_to_missing?` does not fallback to
`Array#respond_to_missing?`.
* Fixed bugs that `StringInquirer#respond_to_missing?` and
`ArrayInquirer#respond_to_missing?` do not fallback to `super`.
*Akira Matsuda*
......
......@@ -18,7 +18,7 @@ class StringInquirer < String
private
def respond_to_missing?(method_name, include_private = false)
method_name[-1] == "?"
(method_name[-1] == "?") || super
end
def method_missing(method_name, *arguments)
......
......@@ -20,4 +20,20 @@ def test_missing_question_mark
def test_respond_to
assert_respond_to @string_inquirer, :development?
end
def test_respond_to_fallback_to_string_respond_to
String.class_eval do
def respond_to_missing?(name, include_private = false)
(name == :bar) || super
end
end
str = ActiveSupport::StringInquirer.new("hello")
assert_respond_to str, :are_you_ready?
assert_respond_to str, :bar
assert_not_respond_to str, :nope
ensure
String.send :undef_method, :respond_to_missing?
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册