ValidationMatcher
@private
# File lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb, line 253 def description description = "ensure #{@attribute} has a length " if @options.key?(:minimum) && @options.key?(:maximum) if @options[:minimum] == @options[:maximum] description << "of exactly #{@options[:minimum]}" else description << "between #{@options[:minimum]} and #{@options[:maximum]}" end else description << "of at least #{@options[:minimum]}" if @options[:minimum] description << "of at most #{@options[:maximum]}" if @options[:maximum] end description end
# File lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb, line 211 def is_at_least(length) @options[:minimum] = length @short_message ||= :too_short self end
# File lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb, line 217 def is_at_most(length) @options[:maximum] = length @long_message ||= :too_long self end
# File lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb, line 223 def is_equal_to(length) @options[:minimum] = length @options[:maximum] = length @short_message ||= :wrong_length @long_message ||= :wrong_length self end
# File lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb, line 268 def matches?(subject) super(subject) translate_messages! lower_bound_matches? && upper_bound_matches? end
# File lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb, line 238 def with_long_message(message) if message @long_message = message end self end
Generated with the Darkfish Rdoc Generator 2.