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.
-
#matcher ⇒ Object
Returns the value of attribute matcher.
-
#times_called ⇒ Object
readonly
Returns the value of attribute times_called.
Instance Method Summary collapse
- #attempt! ⇒ Object
- #attempt? ⇒ Boolean
-
#initialize(double, matcher = nil) ⇒ TimesCalledExpectation
constructor
A new instance of TimesCalledExpectation.
- #terminal? ⇒ Boolean
- #verify ⇒ Object
- #verify! ⇒ Object
Constructor Details
#initialize(double, matcher = nil) ⇒ TimesCalledExpectation
Returns a new instance of TimesCalledExpectation.
7 8 9 10 11 12 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 7 def initialize(double, matcher=nil) @double = double @matcher = matcher @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 |
#matcher ⇒ Object
Returns the value of attribute matcher.
5 6 7 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 5 def matcher @matcher 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
18 19 20 21 22 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 18 def attempt! @times_called += 1 verify_input_error unless @matcher.possible_match?(@times_called) return end |
#attempt? ⇒ Boolean
14 15 16 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 14 def attempt? @matcher.attempt?(@times_called) end |
#terminal? ⇒ Boolean
41 42 43 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 41 def terminal? @matcher.terminal? end |
#verify ⇒ Object
24 25 26 27 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 24 def verify return false unless @matcher.is_a?(TimesCalledMatchers::TimesCalledMatcher) return @matcher.matches?(@times_called) end |
#verify! ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rr/expectations/times_called_expectation.rb', line 29 def verify! unless verify if @verify_backtrace error = Errors::TimesCalledError.new() error.backtrace = @verify_backtrace raise error else raise Errors::TimesCalledError, end end end |