From 823b623fe2de8846c37aa13250010809ac940b57 Mon Sep 17 00:00:00 2001
From: Eloy Duran <eloy.de.enige@gmail.com>
Date: Fri, 21 Nov 2008 09:47:55 +0100
Subject: 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>
---
 activesupport/test/core_ext/object_and_class_ext_test.rb | 7 +++++++
 1 file changed, 7 insertions(+)

(limited to 'activesupport/test/core_ext')

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
-- 
cgit v1.2.3