Class: RR::Expectations::TimesCalledExpectation
- Inherits:
-
Object
- Object
- RR::Expectations::TimesCalledExpectation
- Defined in:
- lib/rr/expectations/times_called_expectation.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#double ⇒ Object
readonly
Returns the value of attribute double.
-
#times_called ⇒ Object
readonly
Returns the value of attribute times_called.
Instance Method Summary collapse
- #attempt ⇒ Object
- #attempt? ⇒ Boolean
-
#initialize(double) ⇒ TimesCalledExpectation
constructor
A new instance of TimesCalledExpectation.
- #terminal? ⇒ Boolean
- #verify ⇒ Object
- #verify! ⇒ Object
Constructor Details
#initialize(double) ⇒ TimesCalledExpectation
Returns a new instance of TimesCalledExpectation.
6 7 8 9 10 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 6 def initialize(double) @double = double @times_called = 0 @verify_backtrace = caller[1..-1] end |
Instance Attribute Details
#double ⇒ Object (readonly)
Returns the value of attribute double.
4 5 6 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 4 def double @double end |
#times_called ⇒ Object (readonly)
Returns the value of attribute times_called.
4 5 6 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 4 def times_called @times_called end |
Instance Method Details
#attempt ⇒ Object
16 17 18 19 20 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 16 def attempt @times_called += 1 verify_input_error unless times_matcher.possible_match?(@times_called) return end |
#attempt? ⇒ Boolean
12 13 14 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 12 def attempt? times_matcher.attempt?(@times_called) end |
#terminal? ⇒ Boolean
33 34 35 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 33 def terminal? times_matcher.terminal? end |
#verify ⇒ Object
22 23 24 25 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 22 def verify return false unless times_matcher.is_a?(TimesCalledMatchers::TimesCalledMatcher) return times_matcher.matches?(@times_called) end |
#verify! ⇒ Object
27 28 29 30 31 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 27 def verify! unless verify raise RR::Errors.build_error(:TimesCalledError, , @verify_backtrace) end end |