The format validator uses :invalid key by default, not :blank.

https://github.com/thoughtbot/shoulda/issues/#issue/119 by adrpac
This commit is contained in:
Justin Case 2011-02-26 09:32:43 +01:00
parent 15bc25ea24
commit 5de1e7788b
2 changed files with 4 additions and 4 deletions

View File

@ -49,7 +49,7 @@ module Shoulda # :nodoc:
def matches?(subject)
super(subject)
@expected_message ||= :blank
@expected_message ||= :invalid
return disallows_value_of(@value_to_fail, @expected_message) if @value_to_fail
allows_value_of(@value_to_pass, @expected_message) if @value_to_pass
end

View File

@ -15,15 +15,15 @@ describe Shoulda::Matchers::ActiveRecord::ValidateFormatOfMatcher do
end
it "should not be valid with alpha in zip" do
@model.should_not validate_format_of(:attr).not_with('1234a')
@model.should validate_format_of(:attr).not_with('1234a')
end
it "should not be valid with to few digits" do
@model.should_not validate_format_of(:attr).not_with('1234')
@model.should validate_format_of(:attr).not_with('1234')
end
it "should not be valid with to many digits" do
@model.should_not validate_format_of(:attr).not_with('123456')
@model.should validate_format_of(:attr).not_with('123456')
end
it "should raise error if you try to call both with and not_with" do