class Easy::Matchers::Validations::ValidateLengthOfMatcher
Public Class Methods
new(attributes)
click to toggle source
Calls superclass method
Easy::Matchers::BaseValidationMatcher::new
# File lib/matchers/validations/length_of.rb, line 9 def initialize(attributes) super(attributes, :length) end
Public Instance Methods
allow_blank(value = true)
click to toggle source
# File lib/matchers/validations/length_of.rb, line 50 def allow_blank(value = true) options[:allow_blank] = value self end
allow_nil(value = true)
click to toggle source
# File lib/matchers/validations/length_of.rb, line 45 def allow_nil(value = true) options[:allow_nil] = value self end
description()
click to toggle source
def is_equal_to
@is = value self
end
# File lib/matchers/validations/length_of.rb, line 75 def description description = "ensure #{ attributes.join(', ') } has a length " # options_desc = [] # options_desc << "with minimum of #{ @minimum }" if @minimum # options_desc << "with maximum of #{ @maximum }" if @maximum # # options_desc << "within the range of #{ @within }" if @within # # options_desc << "as exactly #{ @is }" if @is # options_desc << "with message '#{ @expected_message }'" if @expected_message # super << " #{ options_desc.to_sentence }" description end
if(symbol_name)
click to toggle source
# File lib/matchers/validations/length_of.rb, line 30 def if(symbol_name) options[:if] = symbol_name self end
is_at_least(value)
click to toggle source
# File lib/matchers/validations/length_of.rb, line 65 def is_at_least(value) options[:minimum] = value self end
is_at_most(value)
click to toggle source
# File lib/matchers/validations/length_of.rb, line 60 def is_at_most(value) options[:maximum] = value self end
matches?(subject)
click to toggle source
Calls superclass method
Easy::Matchers::BaseValidationMatcher#matches?
# File lib/matchers/validations/length_of.rb, line 13 def matches?(subject) super(subject) matched_validator = class_name.validators.detect do |validator| validator.kind == type && validator.attributes.sort == attributes.sort && validator.options.sort == options.sort end true if matched_validator end
on(context)
click to toggle source
# File lib/matchers/validations/length_of.rb, line 40 def on(context) options[:on] = context self end
strict(value)
click to toggle source
# File lib/matchers/validations/length_of.rb, line 55 def strict(value) options[:strict] = value self end
unless(symbol_name)
click to toggle source
# File lib/matchers/validations/length_of.rb, line 35 def unless(symbol_name) options[:unless] = symbol_name self end
with_message(message)
click to toggle source
# File lib/matchers/validations/length_of.rb, line 25 def with_message(message) options[:message] = message self end