Skip to content
This repository
Browse code

optimize AllowValueMatcher slightly

  • Loading branch information...
commit 026927b324d67bb1e56b269b372c052479bb662f 1 parent 8724cd2
sigi authored September 05, 2010 gabebw committed March 23, 2012
12  lib/shoulda/matchers/active_model/allow_value_matcher.rb
@@ -58,10 +58,14 @@ def description
58 58
         private
59 59
 
60 60
         def errors_match?
61  
-          @instance.valid?
62  
-          @errors = errors_for_attribute(@instance, @attribute)
63  
-          @errors = [@errors] unless @errors.is_a?(Array)
64  
-          @expected_message ? (errors_match_regexp? || errors_match_string?) : (@errors.compact.any?)
  61
+          if ! @instance.valid?
  62
+            @errors = errors_for_attribute(@instance, @attribute)
  63
+            @errors = [@errors] unless @errors.is_a?(Array)
  64
+            @expected_message ? (errors_match_regexp? || errors_match_string?) : (@errors.compact.any?)
  65
+          else
  66
+            @errors = []
  67
+            false
  68
+          end
65 69
         end
66 70
 
67 71
         def errors_for_attribute(instance, attribute)

0 notes on commit 026927b

Please sign in to comment.
Something went wrong with that request. Please try again.