1
0
Fork 0
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:
Frank Luithle 2010-09-05 17:23:09 +02:00 committed by Gabe Berke-Williams
parent 8724cd2bb2
commit 026927b324

View file

@ -58,10 +58,14 @@ module Shoulda # :nodoc:
private
def errors_match?
@instance.valid?
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)