Created
May 14, 2015 20:20
-
-
Save nwjsmith/33671d46e54f25a0e752 to your computer and use it in GitHub Desktop.
Delegates can use `#public_send` even though they inherit from `BasicObject`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Run options: --seed 53381 | |
# Running: | |
. | |
Finished in 0.000873s, 1145.2393 runs/s, 1145.2393 assertions/s. | |
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
class Decorator < SimpleDelegator | |
def decorated | |
public_send(:original) | |
end | |
def original | |
'wat' | |
end | |
end | |
class DecoratorTest < Minitest::Test | |
def test_delegate_behaves_strangely | |
decorator = Decorator.new(BasicObject.new) | |
assert_equal 'wat', decorator.decorated | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment