aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorVasiliy Ermolovich <younash@gmail.com>2012-05-12 14:07:21 +0300
committerVasiliy Ermolovich <younash@gmail.com>2012-05-12 14:07:21 +0300
commitb8f394f4a381e0b4cefd289df7cf7281bf0f79e9 (patch)
tree8fc648a496936ff01ac3ff47b200bd489d9725d8 /activesupport/test
parent2091e5a65e2950689ad3242d67fdd7b15aa3411b (diff)
downloadrails-b8f394f4a381e0b4cefd289df7cf7281bf0f79e9.tar.gz
rails-b8f394f4a381e0b4cefd289df7cf7281bf0f79e9.tar.bz2
rails-b8f394f4a381e0b4cefd289df7cf7281bf0f79e9.zip
Object#try can't call private methods
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/object_and_class_ext_test.rb14
1 files changed, 13 insertions, 1 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 b027fccab3..98ab82609e 100644
--- a/activesupport/test/core_ext/object_and_class_ext_test.rb
+++ b/activesupport/test/core_ext/object_and_class_ext_test.rb
@@ -101,7 +101,7 @@ class ObjectTryTest < ActiveSupport::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 < ActiveSupport::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