diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-05-24 18:33:41 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2016-05-24 18:33:41 -0300 |
commit | 9a0e09696ad996c9f44565f0a0bf506445484c81 (patch) | |
tree | 36f86f76f98ebbdd2434af29e6b7e5987bf1b851 /activesupport/test | |
parent | acf0bb3f4945f6fda4ac7170b3a0f8fa3becc8f5 (diff) | |
parent | 335fcc214a4b7ea5e10b3610cce6faea4262e4f6 (diff) | |
download | rails-9a0e09696ad996c9f44565f0a0bf506445484c81.tar.gz rails-9a0e09696ad996c9f44565f0a0bf506445484c81.tar.bz2 rails-9a0e09696ad996c9f44565f0a0bf506445484c81.zip |
Merge pull request #23930 from gsamokovarov/module-delegate-missing-to
Introduce Module#delegate_missing_to
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index ae4aed0554..0120aae492 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -83,6 +83,20 @@ Product = Struct.new(:name) do end end +DecoratedTester = Struct.new(:client) do + delegate_missing_to :client +end + +class DecoratedReserved + delegate_missing_to :case + + attr_reader :case + + def initialize(kase) + @case = kase + end +end + class Block def hello? true @@ -316,6 +330,14 @@ class ModuleTest < ActiveSupport::TestCase assert has_block.hello? end + def test_delegate_to_missing_with_method + assert_equal "David", DecoratedTester.new(@david).name + end + + def test_delegate_to_missing_with_reserved_methods + assert_equal "David", DecoratedReserved.new(@david).name + end + def test_parent assert_equal Yz::Zy, Yz::Zy::Cd.parent assert_equal Yz, Yz::Zy.parent |