added more accurate test for add_on_empty

with the current tests, if delete the assignment of is_empty in add_on_empty method
the tests not fail. With this test, if we delete is_empty, the test fails
This commit is contained in:
Angelo capilleri 2013-02-19 18:24:31 +01:00
parent ff259b5249
commit 40c1ee8b7d
1 changed files with 7 additions and 0 deletions

View File

@ -274,6 +274,13 @@ class ErrorsTest < ActiveModel::TestCase
person.errors.add_on_empty :name, :message => 'custom'
end
test "add_on_empty generates message with empty string value" do
person = Person.new
person.name = ''
person.errors.expects(:generate_message).with(:name, :empty, {})
person.errors.add_on_empty :name
end
test "add_on_blank generates message" do
person = Person.new
person.errors.expects(:generate_message).with(:name, :blank, {})