diff options
author | Akira Matsuda <ronnie@dio.jp> | 2017-01-15 03:36:27 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2017-01-15 03:38:06 +0900 |
commit | b99014bf44252e46e4e11e1df7cbded89e3e5465 (patch) | |
tree | 4efdce16d7da1ac881623e05a2f0c1e0e9637485 /activesupport/test | |
parent | b89316fed36096f28f998ec6490151d135695612 (diff) | |
download | rails-b99014bf44252e46e4e11e1df7cbded89e3e5465.tar.gz rails-b99014bf44252e46e4e11e1df7cbded89e3e5465.tar.bz2 rails-b99014bf44252e46e4e11e1df7cbded89e3e5465.zip |
AS::StringInquirer#respond_to_missing? should fallback to super
in case String or any other ancestor class' respond_to_missing? was defined.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/string_inquirer_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/test/string_inquirer_test.rb b/activesupport/test/string_inquirer_test.rb index d41e4d6800..2a5e7d02e4 100644 --- a/activesupport/test/string_inquirer_test.rb +++ b/activesupport/test/string_inquirer_test.rb @@ -20,4 +20,20 @@ class StringInquirerTest < ActiveSupport::TestCase 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 |