Class: Remarkable::ActiveRecord::Matchers::ValidateLengthOfMatcher

Inherits:
Matcher::Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb

Instance Method Summary collapse

Methods included from Helpers

#allow_blank, #allow_nil, #message

Methods included from Default::Helpers

#assert_contains, #assert_does_not_contain

Methods inherited from Matcher::Base

#negative, #spec

Methods included from Matcher::DSL

included, #matches?

Instance Method Details

#descriptionObject



37
38
39
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 37

def description
  "ensure #{expectation}"
end

#failure_messageObject



41
42
43
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 41

def failure_message
  "Expected #{expectation} (#{@missing})"
end

#is(value) ⇒ Object



31
32
33
34
35
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 31

def is(value)
  @options[:minimum] = value
  @options[:maximum] = value
  self
end

#long_message(message) ⇒ Object



18
19
20
21
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 18

def long_message(message)
  warn "[DEPRECATION] :long_message is deprecated for validate_length_of, please use :too_long instead"
  too_long(message)
end

#negative_failure_messageObject



45
46
47
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 45

def negative_failure_message
  "Did not expect #{expectation}"
end

#short_message(message) ⇒ Object



13
14
15
16
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 13

def short_message(message)
  warn "[DEPRECATION] :short_message is deprecated for validate_length_of, please use :too_short instead"
  too_short(message)
end

#within(range) ⇒ Object Also known as: in



23
24
25
26
27
28
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 23

def within(range)
  @behavior = :within
  @options[:minimum] = range.first
  @options[:maximum] = range.last
  self
end