From 5de1e7788b2ecc4d885e770b3b86187afc75d58d Mon Sep 17 00:00:00 2001 From: Justin Case Date: Sat, 26 Feb 2011 09:32:43 +0100 Subject: [PATCH] The format validator uses :invalid key by default, not :blank. https://github.com/thoughtbot/shoulda/issues/#issue/119 by adrpac --- .../matchers/active_record/validate_format_of_matcher.rb | 2 +- .../active_record/validate_format_of_matcher_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/shoulda/matchers/active_record/validate_format_of_matcher.rb b/lib/shoulda/matchers/active_record/validate_format_of_matcher.rb index 73a9313d..73e6b512 100644 --- a/lib/shoulda/matchers/active_record/validate_format_of_matcher.rb +++ b/lib/shoulda/matchers/active_record/validate_format_of_matcher.rb @@ -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 diff --git a/spec/shoulda/active_record/validate_format_of_matcher_spec.rb b/spec/shoulda/active_record/validate_format_of_matcher_spec.rb index 77d14007..472321e6 100644 --- a/spec/shoulda/active_record/validate_format_of_matcher_spec.rb +++ b/spec/shoulda/active_record/validate_format_of_matcher_spec.rb @@ -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