Class: NoBrainer::Matchers::Validations::ValidateLengthOfMatcher
Instance Method Summary
collapse
#failure_message_for_should, #failure_message_for_should_not, #on, #with_message
Constructor Details
Returns a new instance of ValidateLengthOfMatcher.
7
8
9
|
# File 'lib/matchers/validations/length_of.rb', line 7
def initialize(name)
super(name, :length)
end
|
Instance Method Details
#as_exactly(value) ⇒ Object
Also known as:
is
29
30
31
32
|
# File 'lib/matchers/validations/length_of.rb', line 29
def as_exactly(value)
@is = value
self
end
|
#description ⇒ Object
46
47
48
49
50
51
52
53
|
# File 'lib/matchers/validations/length_of.rb', line 46
def description
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
"#{super} #{options_desc.to_sentence}"
end
|
#matches?(actual) ⇒ Boolean
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/matchers/validations/length_of.rb', line 35
def matches?(actual)
return false unless @result = super(actual)
check_maximum if @maximum
check_minimum if @minimum
check_range if @within
check_exact if @is
@result
end
|
#with_maximum(value) ⇒ Object
Also known as:
less_than
11
12
13
14
|
# File 'lib/matchers/validations/length_of.rb', line 11
def with_maximum(value)
@maximum = value
self
end
|
#with_minimum(value) ⇒ Object
Also known as:
greater_than
17
18
19
20
|
# File 'lib/matchers/validations/length_of.rb', line 17
def with_minimum(value)
@minimum = value
self
end
|
#within(value) ⇒ Object
Also known as:
in
23
24
25
26
|
# File 'lib/matchers/validations/length_of.rb', line 23
def within(value)
@within = value
self
end
|