From d5fbb04fab6f598b2ad5a4763672504fa81466af Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sun, 15 Jan 2017 02:38:21 +0900 Subject: AS::ArrayInquirer#respond_to_missing? should fallback to super in case Array or any other ancestor class' respond_to_missing? was defined. --- activesupport/test/array_inquirer_test.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/array_inquirer_test.rb b/activesupport/test/array_inquirer_test.rb index 4d3f5b001c..3ed48dd49d 100644 --- a/activesupport/test/array_inquirer_test.rb +++ b/activesupport/test/array_inquirer_test.rb @@ -38,4 +38,18 @@ class ArrayInquirerTest < ActiveSupport::TestCase assert_instance_of ActiveSupport::ArrayInquirer, result assert_equal @array_inquirer, result end + + def test_respond_to_fallback_to_array_respond_to + arr = ActiveSupport::ArrayInquirer.new([:x]) + # This kind of emulates a situation that Array#respond_to_missing? is defined + arr.singleton_class.class_eval do + def respond_to_missing?(name, _include_private = false) + (name == :foo) || super + end + end + + assert_respond_to arr, :can_you_hear_me? + assert_respond_to arr, :foo + assert_not_respond_to arr, :nope + end end -- cgit v1.2.3