aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/module_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/core_ext/module_test.rb')
-rw-r--r--activesupport/test/core_ext/module_test.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index 071eefcb29..46d63748bc 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -38,6 +38,7 @@ end
Invoice = Struct.new(:client) do
delegate :street, :city, :name, :to => :client, :prefix => true
+ delegate :street, :city, :name, :to => :client, :prefix => :customer
end
class Name
@@ -97,6 +98,14 @@ class ModuleTest < Test::Unit::TestCase
assert_equal invoice.client_city, "Chicago"
end
+ def test_delegation_custom_prefix
+ david = Someone.new("David", Somewhere.new("Paulina", "Chicago"))
+ invoice = Invoice.new(david)
+ assert_equal invoice.customer_name, "David"
+ assert_equal invoice.customer_street, "Paulina"
+ assert_equal invoice.customer_city, "Chicago"
+ end
+
def test_parent
assert_equal Yz::Zy, Yz::Zy::Cd.parent
assert_equal Yz, Yz::Zy.parent