From 8e24a6e9b2b147f2c51fb03aa02543f213acab34 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Sat, 26 Dec 2015 01:13:29 -0500 Subject: [PATCH] numericality: Do not run all submatchers This commit changes the numericality matcher so that when running submatchers, the matcher will stop on the first one that fails instead of running them all. Since all of the submatchers modify the same record, running all of them is actually bad since it could possibly make the failure message confusing (since the record will be in a mixed state). --- .../active_model/validate_numericality_of_matcher.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb b/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb index 58312edbe..5e9fa0df0 100644 --- a/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +++ b/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb @@ -549,11 +549,7 @@ def update_diff_to_compare(matcher) end def first_failing_submatcher - failing_submatchers.first - end - - def failing_submatchers - @_failing_submatchers ||= @submatchers.select do |submatcher| + @_failing_submatchers ||= @submatchers.detect do |submatcher| !submatcher.matches?(@subject) end end