diff options
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.rb | 18 |
1 files changed, 15 insertions, 3 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 782a01213d..98ab82609e 100644 --- a/activesupport/test/core_ext/object_and_class_ext_test.rb +++ b/activesupport/test/core_ext/object_and_class_ext_test.rb @@ -59,7 +59,7 @@ class ObjectTests < ActiveSupport::TestCase end end -class ObjectInstanceVariableTest < Test::Unit::TestCase +class ObjectInstanceVariableTest < ActiveSupport::TestCase def setup @source, @dest = Object.new, Object.new @source.instance_variable_set(:@bar, 'bar') @@ -91,7 +91,7 @@ class ObjectInstanceVariableTest < Test::Unit::TestCase end end -class ObjectTryTest < Test::Unit::TestCase +class ObjectTryTest < ActiveSupport::TestCase def setup @string = "Hello" end @@ -101,7 +101,7 @@ class ObjectTryTest < Test::Unit::TestCase assert !@string.respond_to?(method) assert_raise(NoMethodError) { @string.try(method) } end - + def test_nonexisting_method_with_arguments method = :undefined_method assert !@string.respond_to?(method) @@ -138,4 +138,16 @@ class ObjectTryTest < Test::Unit::TestCase nil.try { ran = true } assert_equal false, ran end + + def test_try_with_private_method + klass = Class.new do + private + + def private_method + 'private method' + end + end + + assert_raise(NoMethodError) { klass.new.try(:private_method) } + end end |