Class: Remarkable::ActiveRecord::Matchers::ValidateLengthOfMatcher
- Inherits:
-
Matcher::Base
- Object
- Matcher::Base
- Remarkable::ActiveRecord::Matchers::ValidateLengthOfMatcher
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
#assert_contains, #assert_does_not_contain
#negative, #spec
included, #matches?
Instance Method Details
#description ⇒ Object
39
40
41
|
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 39
def description
"ensure #{expectation}"
end
|
#failure_message ⇒ Object
43
44
45
|
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 43
def failure_message
"Expected #{expectation} (#{@missing})"
end
|
#is(value) ⇒ Object
33
34
35
36
37
|
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 33
def is(value)
@options[:minimum] = value
@options[:maximum] = value
self
end
|
#message(message) ⇒ Object
If message is supplied, reassign it properly to :short_message and :long_message. This is ActiveRecord default behavior when the validation is :maximum, :minimum or :is.
17
18
19
20
21
22
23
|
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 17
def message(message)
if [:is, :minimum, :maximum].include? @behavior
short_message(message)
long_message(message)
end
self
end
|
#negative_failure_message ⇒ Object
47
48
49
|
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 47
def negative_failure_message
"Did not expect #{expectation}"
end
|
#within(range) ⇒ Object
Also known as:
in
25
26
27
28
29
30
|
# File 'lib/remarkable/active_record/macros/validations/validate_length_of_matcher.rb', line 25
def within(range)
@behavior = :within
@options[:minimum] = range.first
@options[:maximum] = range.last
self
end
|