Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

optimize AllowValueMatcher slightly

  • Loading branch information...
commit 026927b324d67bb1e56b269b372c052479bb662f 1 parent 8724cd2
@sigi sigi authored gabebw committed
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/shoulda/matchers/active_model/allow_value_matcher.rb
View
12 lib/shoulda/matchers/active_model/allow_value_matcher.rb
@@ -58,10 +58,14 @@ def description
private
def errors_match?
- @instance.valid?
- @errors = errors_for_attribute(@instance, @attribute)
- @errors = [@errors] unless @errors.is_a?(Array)
- @expected_message ? (errors_match_regexp? || errors_match_string?) : (@errors.compact.any?)
+ if ! @instance.valid?
+ @errors = errors_for_attribute(@instance, @attribute)
+ @errors = [@errors] unless @errors.is_a?(Array)
+ @expected_message ? (errors_match_regexp? || errors_match_string?) : (@errors.compact.any?)
+ else
+ @errors = []
+ false
+ end
end
def errors_for_attribute(instance, attribute)
Please sign in to comment.
Something went wrong with that request. Please try again.