diff options
Diffstat (limited to 'activesupport/test/core_ext/module_test.rb')
-rw-r--r-- | activesupport/test/core_ext/module_test.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 5d9cdf22c2..a95cf1591f 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -26,14 +26,10 @@ module Yz end end -class De -end - Somewhere = Struct.new(:street, :city) Someone = Struct.new(:name, :place) do delegate :street, :city, :to_f, :to => :place - delegate :state, :to => :@place delegate :upcase, :to => "place.city" end @@ -47,6 +43,14 @@ Project = Struct.new(:description, :person) do delegate :to_f, :to => :description, :allow_nil => true end +Developer = Struct.new(:client) do + delegate :name, :to => :client, :prefix => nil +end + +Tester = Struct.new(:client) do + delegate :name, :to => :client, :prefix => false +end + class Name delegate :upcase, :to => :@full_name @@ -97,6 +101,11 @@ class ModuleTest < Test::Unit::TestCase assert_equal invoice.customer_city, "Chicago" end + def test_delegation_prefix_with_nil_or_false + assert_equal Developer.new(@david).name, "David" + assert_equal Tester.new(@david).name, "David" + end + def test_delegation_prefix_with_instance_variable assert_raise ArgumentError do Class.new do |