Class: NotAMock::Matchers::TimesMatcher
- Inherits:
-
CallMatcher
- Object
- CallMatcher
- NotAMock::Matchers::TimesMatcher
- Defined in:
- lib/not_a_mock/matchers/times_matcher.rb
Overview
Matcher for once
, twice
, and
exactly(n).times
Instance Attribute Summary
Attributes inherited from CallMatcher
Instance Method Summary collapse
- #failure_message_without_parents ⇒ Object
-
#initialize(times, parent = nil) ⇒ TimesMatcher
constructor
A new instance of TimesMatcher.
- #matches_without_parents? ⇒ Boolean
- #times ⇒ Object
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
Returns a new instance of 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 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 |
#times ⇒ Object
27 28 29 |
# File 'lib/not_a_mock/matchers/times_matcher.rb', line 27 def times self end |