diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-09-15 03:42:54 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-09-15 03:42:54 +0000 |
commit | 643571ca25bc2fcc701e6def0975f56fe10a732f (patch) | |
tree | a6e5aa35aa9e86c349e6620146d0b3d4470373e7 /activesupport/test/core_ext | |
parent | 3d3ba58dbb2cfd4bbb0c1c868d754134a6f9ea3c (diff) | |
download | rails-643571ca25bc2fcc701e6def0975f56fe10a732f.tar.gz rails-643571ca25bc2fcc701e6def0975f56fe10a732f.tar.bz2 rails-643571ca25bc2fcc701e6def0975f56fe10a732f.zip |
alias_method_chain yields method target and punctuation to simplify wrapper method definition. Used by the deprecate module method.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5113 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 9d86c84e21..bbf6dd1640 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -100,9 +100,12 @@ end module BarMethodAliaser def self.included(foo_class) + foo_class.send :include, BarMethods foo_class.alias_method_chain :bar, :baz end +end +module BarMethods def bar_with_baz bar_without_baz << '_with_baz' end @@ -203,4 +206,16 @@ class MethodAliasingTest < Test::Unit::TestCase FooClassWithBarMethod.alias_method_chain :quux?, :baz! end end + + def test_alias_method_chain_yields_target_and_punctuation + FooClassWithBarMethod.send(:define_method, :quux?, Proc.new { }) + FooClassWithBarMethod.send :include, BarMethods + block_called = false + FooClassWithBarMethod.alias_method_chain :quux?, :baz do |target, punctuation| + block_called = true + assert_equal 'quux', target + assert_equal '?', punctuation + end + assert block_called + end end |