aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-04-09 19:53:31 +0930
committerMatthew Draper <matthew@trebex.net>2017-04-09 20:00:12 +0930
commit071882e8ef6835cec7eb4e6ff965b99f4563b7aa (patch)
tree5cccc176c6e8222395d786151d52cdd89edb99ac /activesupport/test
parent81555776d4006f3cd31ae49e6ab385ea3327f036 (diff)
downloadrails-071882e8ef6835cec7eb4e6ff965b99f4563b7aa.tar.gz
rails-071882e8ef6835cec7eb4e6ff965b99f4563b7aa.tar.bz2
rails-071882e8ef6835cec7eb4e6ff965b99f4563b7aa.zip
delegate_to_missing doesn't delegate private methods
So we shouldn't claim they're there, even when asked explicitly.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/module_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index a17438bf4d..6d649f747c 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -356,6 +356,16 @@ class ModuleTest < ActiveSupport::TestCase
assert_match(/undefined method `my_fake_method' for/, e.message)
end
+ def test_delegate_to_missing_affects_respond_to
+ assert DecoratedTester.new(@david).respond_to?(:name)
+ assert_not DecoratedTester.new(@david).respond_to?(:private_name)
+ assert_not DecoratedTester.new(@david).respond_to?(:my_fake_method)
+
+ assert DecoratedTester.new(@david).respond_to?(:name, true)
+ assert_not DecoratedTester.new(@david).respond_to?(:private_name, true)
+ assert_not DecoratedTester.new(@david).respond_to?(:my_fake_method, true)
+ end
+
def test_delegate_with_case
event = Event.new(Tester.new)
assert_equal 1, event.foo