From e98f2a74eb20e2b0866b66130501f8480798dd4c Mon Sep 17 00:00:00 2001 From: Ari Pollak Date: Wed, 22 Oct 2014 18:34:43 -0400 Subject: Bring try! into parity with try. Based on commit 5e51bdda. --- activesupport/test/core_ext/object/try_test.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'activesupport/test') diff --git a/activesupport/test/core_ext/object/try_test.rb b/activesupport/test/core_ext/object/try_test.rb index 225c20fa36..efc6beaf02 100644 --- a/activesupport/test/core_ext/object/try_test.rb +++ b/activesupport/test/core_ext/object/try_test.rb @@ -30,10 +30,6 @@ class ObjectTryTest < ActiveSupport::TestCase assert_raise(NoMethodError) { @string.try!(method, 'llo', 'y') } end - def test_try_only_block_bang - assert_equal @string.reverse, @string.try! { |s| s.reverse } - end - def test_valid_method assert_equal 5, @string.try(:size) end @@ -59,6 +55,10 @@ class ObjectTryTest < ActiveSupport::TestCase assert_equal @string.reverse, @string.try { |s| s.reverse } end + def test_try_only_block_bang + assert_equal @string.reverse, @string.try! { |s| s.reverse } + end + def test_try_only_block_nil ran = false nil.try { ran = true } @@ -69,6 +69,10 @@ class ObjectTryTest < ActiveSupport::TestCase assert_equal @string.reverse, @string.try { reverse } end + def test_try_with_instance_eval_block_bang + assert_equal @string.reverse, @string.try! { reverse } + end + def test_try_with_private_method_bang klass = Class.new do private -- cgit v1.2.3