Class: NotAMock::Matchers::TimesMatcher
Overview
Matcher for once, twice, and
exactly(n).times
Instance Attribute Summary
Attributes inherited from CallMatcher
#calls
Instance Method Summary
collapse
Methods inherited from CallMatcher
#and_returned, #exactly, #failure_message, #matched?, #matches?, #negative_failure_message, #once, #twice, #with, #without_args
Constructor Details
#initialize(times, parent = nil) ⇒ TimesMatcher
9
10
11
12
|
# File 'lib/not_a_mock/matchers/times_matcher.rb', line 9
def initialize(times, parent = nil)
super parent
@times = times
end
|
Instance Method Details
#failure_message_without_parents ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/not_a_mock/matchers/times_matcher.rb', line 19
def failure_message_without_parents
if matched?
", #{times_in_english(@parent.calls.length)}"
else
", but #{times_in_english(@parent.calls.length, true)}"
end
end
|
#matches_without_parents? ⇒ Boolean
14
15
16
17
|
# File 'lib/not_a_mock/matchers/times_matcher.rb', line 14
def matches_without_parents?
@calls = @parent.calls
@calls.length == @times
end
|
27
28
29
|
# File 'lib/not_a_mock/matchers/times_matcher.rb', line 27
def times
self
end
|