1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00

Updated docs for the validate_format_of matcher

* Reflects correct default error message (:invalid)
* Also added extra tests for invalid formats
This commit is contained in:
Ryan McGeary 2011-02-26 09:11:47 -05:00
parent 5de1e7788b
commit 70b706e85a
2 changed files with 6 additions and 3 deletions

View file

@ -8,7 +8,7 @@ module Shoulda # :nodoc:
# Options:
# * <tt>with_message</tt> - value the test expects to find in
# <tt>errors.on(:attribute)</tt>. <tt>Regexp</tt> or <tt>String</tt>.
# Defaults to the translation for <tt>:blank</tt>.
# Defaults to the translation for <tt>:invalid</tt>.
# * <tt>with(string to test against)</tt>
# * <tt>not_with(string to test against)</tt>
#

View file

@ -15,14 +15,17 @@ describe Shoulda::Matchers::ActiveRecord::ValidateFormatOfMatcher do
end
it "should not be valid with alpha in zip" do
@model.should_not validate_format_of(:attr).with('1234a')
@model.should validate_format_of(:attr).not_with('1234a')
end
it "should not be valid with to few digits" do
it "should not be valid with too few digits" do
@model.should_not validate_format_of(:attr).with('1234')
@model.should validate_format_of(:attr).not_with('1234')
end
it "should not be valid with to many digits" do
it "should not be valid with too many digits" do
@model.should_not validate_format_of(:attr).with('123456')
@model.should validate_format_of(:attr).not_with('123456')
end