aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/module_test.rb
diff options
context:
space:
mode:
authorLi Ellis Gallardo <lellisga@gmail.com>2013-04-25 17:00:13 -0500
committerLi Ellis Gallardo <lellisga@gmail.com>2013-04-25 21:36:22 -0500
commitccbe02343934956d3bb11c7167e0493f9d8f08fd (patch)
treeeaa4b31acfb5a306fdb1c5c680fec17f6a56078d /activesupport/test/core_ext/module_test.rb
parentfaa2c71deef44ded8ef73513e63229d057552540 (diff)
downloadrails-ccbe02343934956d3bb11c7167e0493f9d8f08fd.tar.gz
rails-ccbe02343934956d3bb11c7167e0493f9d8f08fd.tar.bz2
rails-ccbe02343934956d3bb11c7167e0493f9d8f08fd.zip
Delegation method bug
Add documentation and test to delegation method that make sure we're aware that when a delegated object is not nil or false and doesn't respond to the method it will still raise a NoMethodError exception.
Diffstat (limited to 'activesupport/test/core_ext/module_test.rb')
-rw-r--r--activesupport/test/core_ext/module_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb
index 82249ddd1b..9a8582075d 100644
--- a/activesupport/test/core_ext/module_test.rb
+++ b/activesupport/test/core_ext/module_test.rb
@@ -171,6 +171,11 @@ class ModuleTest < ActiveSupport::TestCase
assert_nil rails.name
end
+ def test_delegation_with_allow_nil_and_invalid_value
+ rails = Project.new("Rails", "David")
+ assert_raise(NoMethodError) { rails.name }
+ end
+
def test_delegation_with_allow_nil_and_nil_value_and_prefix
Project.class_eval do
delegate :name, :to => :person, :allow_nil => true, :prefix => true