mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
"raise NoMethodError" raises NoMethodError. Raise it with NoMethodError.new instead.
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
committed by
Pratik Naik
parent
5cf932344a
commit
5c97d4ff29
@@ -233,8 +233,9 @@ class AttributeMethodsTest < ActiveRecord::TestCase
|
||||
|
||||
topic = @target.new(:title => "The pros and cons of programming naked.")
|
||||
assert !topic.respond_to?(:title)
|
||||
assert_raise(NoMethodError) { topic.title }
|
||||
topic.send(:title)
|
||||
exception = assert_raise(NoMethodError) { topic.title }
|
||||
assert_equal "Attempt to call private method", exception.message
|
||||
assert_equal "I'm private", topic.send(:title)
|
||||
end
|
||||
|
||||
def test_write_attributes_respect_access_control
|
||||
@@ -242,7 +243,8 @@ class AttributeMethodsTest < ActiveRecord::TestCase
|
||||
|
||||
topic = @target.new
|
||||
assert !topic.respond_to?(:title=)
|
||||
assert_raise(NoMethodError) { topic.title = "Pants"}
|
||||
exception = assert_raise(NoMethodError) { topic.title = "Pants"}
|
||||
assert_equal "Attempt to call private method", exception.message
|
||||
topic.send(:title=, "Very large pants")
|
||||
end
|
||||
|
||||
@@ -251,7 +253,8 @@ class AttributeMethodsTest < ActiveRecord::TestCase
|
||||
|
||||
topic = @target.new(:title => "Isaac Newton's pants")
|
||||
assert !topic.respond_to?(:title?)
|
||||
assert_raise(NoMethodError) { topic.title? }
|
||||
exception = assert_raise(NoMethodError) { topic.title? }
|
||||
assert_equal "Attempt to call private method", exception.message
|
||||
assert topic.send(:title?)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user