From 643571ca25bc2fcc701e6def0975f56fe10a732f Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 15 Sep 2006 03:42:54 +0000 Subject: 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 --- activesupport/test/core_ext/module_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'activesupport/test/core_ext/module_test.rb') 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 -- cgit v1.2.3