aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/object_and_class_ext_test.rb
diff options
context:
space:
mode:
authorEloy Duran <eloy.de.enige@gmail.com>2008-11-21 09:47:55 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-11-24 18:53:48 +0100
commit823b623fe2de8846c37aa13250010809ac940b57 (patch)
tree7bf0e7e557bdedb57226cd35fef12f7e9fbbea4b /activesupport/test/core_ext/object_and_class_ext_test.rb
parentfffb1da3f22852c722dbc4436ec7c924435d29a5 (diff)
downloadrails-823b623fe2de8846c37aa13250010809ac940b57.tar.gz
rails-823b623fe2de8846c37aa13250010809ac940b57.tar.bz2
rails-823b623fe2de8846c37aa13250010809ac940b57.zip
Allow optional arguments and/or block for Object#try like Object#send does. [#1425 state:resolved]
Original suggestion by Pat Nakajima. Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activesupport/test/core_ext/object_and_class_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/object_and_class_ext_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb
index fbdce56ac2..2f79b6f67f 100644
--- a/activesupport/test/core_ext/object_and_class_ext_test.rb
+++ b/activesupport/test/core_ext/object_and_class_ext_test.rb
@@ -271,4 +271,11 @@ class ObjectTryTest < Test::Unit::TestCase
assert_equal 5, @string.try(:size)
end
+ def test_argument_forwarding
+ assert_equal 'Hey', @string.try(:sub, 'llo', 'y')
+ end
+
+ def test_block_forwarding
+ assert_equal 'Hey', @string.try(:sub, 'llo') { |match| 'y' }
+ end
end