mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
optimize AllowValueMatcher slightly
This commit is contained in:
parent
8724cd2bb2
commit
026927b324
1 changed files with 8 additions and 4 deletions
|
@ -58,10 +58,14 @@ module Shoulda # :nodoc:
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue