diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2014-08-29 15:32:24 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2014-08-29 15:32:24 -0700 |
commit | 5e51bdda59c9ba8e5faf86294e3e431bd45f1830 (patch) | |
tree | 076ef97191adbe905dce5893dd31bc2f48624c1e /activesupport/test | |
parent | 39691ba2f5664aa83720fa3c2a1ca14937d29009 (diff) | |
download | rails-5e51bdda59c9ba8e5faf86294e3e431bd45f1830.tar.gz rails-5e51bdda59c9ba8e5faf86294e3e431bd45f1830.tar.bz2 rails-5e51bdda59c9ba8e5faf86294e3e431bd45f1830.zip |
We tenderized the wrong method! Object#try already had the yield option, just needed some tenderloving instance_eval to fit the bill
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/object/blank_test.rb | 10 | ||||
-rw-r--r-- | activesupport/test/core_ext/object/try_test.rb | 4 |
2 files changed, 4 insertions, 10 deletions
diff --git a/activesupport/test/core_ext/object/blank_test.rb b/activesupport/test/core_ext/object/blank_test.rb index 4deac4b0aa..d6c69bd582 100644 --- a/activesupport/test/core_ext/object/blank_test.rb +++ b/activesupport/test/core_ext/object/blank_test.rb @@ -28,14 +28,4 @@ class BlankTest < ActiveSupport::TestCase BLANK.each { |v| assert_equal false, v.present?, "#{v.inspect} should not be present" } NOT.each { |v| assert_equal true, v.present?, "#{v.inspect} should be present" } end - - def test_presence - BLANK.each { |v| assert_equal nil, v.presence, "#{v.inspect}.presence should return nil" } - NOT.each { |v| assert_equal v, v.presence, "#{v.inspect}.presence should return self" } - end - - def test_presence_with_a_block - assert_equal "THIS WAS TENDERLOVE'S IDEA", "this was tenderlove's idea".presence { upcase } || "Nobody" - assert_equal "Nobody", nil.presence { upcase } || "Nobody" - end end diff --git a/activesupport/test/core_ext/object/try_test.rb b/activesupport/test/core_ext/object/try_test.rb index 8b754ced53..225c20fa36 100644 --- a/activesupport/test/core_ext/object/try_test.rb +++ b/activesupport/test/core_ext/object/try_test.rb @@ -65,6 +65,10 @@ class ObjectTryTest < ActiveSupport::TestCase assert_equal false, ran end + def test_try_with_instance_eval_block + assert_equal @string.reverse, @string.try { reverse } + end + def test_try_with_private_method_bang klass = Class.new do private |