mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
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:
parent
15bc25ea24
commit
5de1e7788b
2 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue