aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorAnton Khamets <colorfulfool@gmail.com>2017-08-13 01:23:17 +0300
committerRafael França <rafaelmfranca@gmail.com>2017-08-12 18:23:17 -0400
commite6c310b3f8144e9e08bc20a16d9889974d890030 (patch)
treeb05891804e5a20234cbe42d4ea9ab042b3015012 /activesupport/test
parent98360a96cc1e0bb6ab9eb31f421a36439e66eefc (diff)
downloadrails-e6c310b3f8144e9e08bc20a16d9889974d890030.tar.gz
rails-e6c310b3f8144e9e08bc20a16d9889974d890030.tar.bz2
rails-e6c310b3f8144e9e08bc20a16d9889974d890030.zip
Test for the new exception of delegate_missing_to (#30191)
* Add test for the new exception of delegate_missing_to * Add a changelog entry * Only check for nil if NoMethodError was raised * Make method private * Have to pass both target name and value * Inline the re-raise [Rafael Mendonça França + Anton Khamets]
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/module_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index 69c8a312d8..e918823074 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -374,6 +374,14 @@ class ModuleTest < ActiveSupport::TestCase
assert_match(/undefined method `my_fake_method' for/, e.message)
end
+ def test_delegate_missing_to_raises_delegation_error_if_target_nil
+ e = assert_raises(Module::DelegationError) do
+ DecoratedTester.new(nil).name
+ end
+
+ assert_equal "name delegated to client, but client is nil", e.message
+ end
+
def test_delegate_missing_to_affects_respond_to
assert DecoratedTester.new(@david).respond_to?(:name)
assert_not DecoratedTester.new(@david).respond_to?(:private_name)