aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/object_and_class_ext_test.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2012-07-27 12:20:50 -0500
committerDavid Heinemeier Hansson <david@loudthinking.com>2012-07-27 12:22:38 -0500
commit99ea1a875b06feb4346869f371e2a57a2cc0a0fc (patch)
tree1f05fdcff4afc50dc39537b50c595fc5acde059e /activesupport/test/core_ext/object_and_class_ext_test.rb
parent3205c768b7c592e5b96fdf6a6dd0fd3c2c9e5775 (diff)
downloadrails-99ea1a875b06feb4346869f371e2a57a2cc0a0fc.tar.gz
rails-99ea1a875b06feb4346869f371e2a57a2cc0a0fc.tar.bz2
rails-99ea1a875b06feb4346869f371e2a57a2cc0a0fc.zip
will now return nil instead of raise a NoMethodError if the receiving object does not implement the method
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.rb8
1 files changed, 4 insertions, 4 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 98ab82609e..5dd965f405 100644
--- a/activesupport/test/core_ext/object_and_class_ext_test.rb
+++ b/activesupport/test/core_ext/object_and_class_ext_test.rb
@@ -99,13 +99,13 @@ class ObjectTryTest < ActiveSupport::TestCase
def test_nonexisting_method
method = :undefined_method
assert !@string.respond_to?(method)
- assert_raise(NoMethodError) { @string.try(method) }
+ assert_nil @string.try(method)
end
def test_nonexisting_method_with_arguments
method = :undefined_method
assert !@string.respond_to?(method)
- assert_raise(NoMethodError) { @string.try(method, 'llo', 'y') }
+ assert_nil @string.try(method, 'llo', 'y')
end
def test_valid_method
@@ -124,7 +124,7 @@ class ObjectTryTest < ActiveSupport::TestCase
assert_nil nil.try(:to_s)
assert_nil nil.try(:to_i)
end
-
+
def test_false_try
assert_equal 'false', false.try(:to_s)
end
@@ -148,6 +148,6 @@ class ObjectTryTest < ActiveSupport::TestCase
end
end
- assert_raise(NoMethodError) { klass.new.try(:private_method) }
+ assert_nil klass.new.try(:private_method)
end
end