diff options
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 04692f1484..6e341480d1 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -92,6 +92,16 @@ DecoratedTester = Struct.new(:client) do delegate_missing_to :client end +class DecoratedMissingAllowNil + delegate_missing_to :case, allow_nil: true + + attr_reader :case + + def initialize(kase) + @case = kase + end +end + class DecoratedReserved delegate_missing_to :case @@ -382,6 +392,10 @@ class ModuleTest < ActiveSupport::TestCase assert_equal "name delegated to client, but client is nil", e.message end + def test_delegate_missing_to_returns_nil_if_allow_nil_and_nil_target + assert_nil DecoratedMissingAllowNil.new(nil).name + end + def test_delegate_missing_to_affects_respond_to assert_respond_to DecoratedTester.new(@david), :name assert_not_respond_to DecoratedTester.new(@david), :private_name |