From 2e2f3f5a469cb441e52fb161647ea5fd27d98d81 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Mon, 15 Aug 2011 16:07:49 +0100 Subject: Add a test for delegating a method ending in '=' as this is a special case. --- activesupport/test/core_ext/module_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index a24f013d4f..d4ce81fdfa 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -27,6 +27,8 @@ module Yz end Somewhere = Struct.new(:street, :city) do + attr_accessor :name + protected def protected_method @@ -40,6 +42,7 @@ end class Someone < Struct.new(:name, :place) delegate :street, :city, :to_f, :protected_method, :private_method, :to => :place + delegate :name=, :to => :place, :prefix => true delegate :upcase, :to => "place.city" FAILED_DELEGATE_LINE = __LINE__ + 1 @@ -85,6 +88,11 @@ class ModuleTest < Test::Unit::TestCase assert_equal "Chicago", @david.city end + def test_delegation_to_assignment_method + @david.place_name = "Fred" + assert_equal "Fred", @david.place.name + end + def test_delegation_to_protected_method assert_raise(NoMethodError) { @david.protected_method } end -- cgit v1.2.3