From 18f668051ee39d81db2784f317c69dc2864acb36 Mon Sep 17 00:00:00 2001 From: Gabe Berke-Williams Date: Fri, 11 May 2012 10:28:38 -0400 Subject: [PATCH] Extract method and clear up what's happening. --- .../active_model/ensure_length_of_matcher.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb b/lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb index daf29fc8..12a353bd 100644 --- a/lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb +++ b/lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb @@ -93,11 +93,7 @@ module Shoulda # :nodoc: def matches?(subject) super(subject) translate_messages! - disallows_lower_length? && - allows_minimum_length? && - ((@options[:minimum] == @options[:maximum]) || - (disallows_higher_length? && - allows_maximum_length?)) + lower_bound_matches? && upper_bound_matches? end private @@ -118,6 +114,14 @@ module Shoulda # :nodoc: end end + def lower_bound_matches? + disallows_lower_length? && allows_minimum_length? + end + + def upper_bound_matches? + disallows_higher_length? && allows_maximum_length? + end + def disallows_lower_length? if @options.key?(:minimum) @options[:minimum] == 0 ||