Class: RR::Double
- Inherits:
-
Object
- Object
- RR::Double
- Includes:
- Space::Reader
- Defined in:
- lib/rr/double.rb
Overview
RR::Double is the use case for a method call. It has the ArgumentEqualityExpectation, TimesCalledExpectation, and the implementation.
Instance Attribute Summary (collapse)
-
- (Object) definition
readonly
Returns the value of attribute definition.
-
- (Object) double_injection
readonly
Returns the value of attribute double_injection.
-
- (Object) times_called
readonly
Returns the value of attribute times_called.
-
- (Object) times_called_expectation
readonly
Returns the value of attribute times_called_expectation.
Instance Method Summary (collapse)
-
- (Boolean) attempt?
Double#attempt? returns true when the TimesCalledExpectation is satisfied.
-
- (Boolean) exact_match?(*arguments)
Double#exact_match? returns true when the passed in arguments exactly match the ArgumentEqualityExpectation arguments.
-
- (Object) expected_arguments
The Arguments that this Double expects.
- - (Object) formatted_name
- - (Boolean) implementation_is_original_method?
-
- (Double) initialize(double_injection, definition)
constructor
A new instance of Double.
- - (Object) method_call(args)
-
- (Object) method_name
The method name that this Double is attatched to.
- - (Boolean) terminal?
-
- (Object) times_matcher
The TimesCalledMatcher for the TimesCalledExpectation.
-
- (Object) verify
Double#verify verifies the the TimesCalledExpectation is satisfied for this double.
-
- (Boolean) wildcard_match?(*arguments)
Double#wildcard_match? returns true when the passed in arguments wildcard match the ArgumentEqualityExpectation arguments.
Methods included from Space::Reader
Constructor Details
- (Double) initialize(double_injection, definition)
A new instance of Double
22 23 24 25 26 27 28 29 30 |
# File 'lib/rr/double.rb', line 22 def initialize(double_injection, definition) @double_injection = double_injection @definition = definition @times_called = 0 @times_called_expectation = Expectations::TimesCalledExpectation.new(self) definition.double = self verify_method_signature if definition.verify_method_signature? double_injection.register_double self end |
Instance Attribute Details
- (Object) definition (readonly)
Returns the value of attribute definition
19 20 21 |
# File 'lib/rr/double.rb', line 19 def definition @definition end |
- (Object) double_injection (readonly)
Returns the value of attribute double_injection
19 20 21 |
# File 'lib/rr/double.rb', line 19 def double_injection @double_injection end |
- (Object) times_called (readonly)
Returns the value of attribute times_called
19 20 21 |
# File 'lib/rr/double.rb', line 19 def times_called @times_called end |
- (Object) times_called_expectation (readonly)
Returns the value of attribute times_called_expectation
19 20 21 |
# File 'lib/rr/double.rb', line 19 def times_called_expectation @times_called_expectation end |
Instance Method Details
- (Boolean) attempt?
Double#attempt? returns true when the TimesCalledExpectation is satisfied.
46 47 48 49 |
# File 'lib/rr/double.rb', line 46 def attempt? verify_times_matcher_is_set times_called_expectation.attempt? end |
- (Boolean) exact_match?(*arguments)
Double#exact_match? returns true when the passed in arguments exactly match the ArgumentEqualityExpectation arguments.
34 35 36 |
# File 'lib/rr/double.rb', line 34 def exact_match?(*arguments) definition.exact_match?(*arguments) end |
- (Object) expected_arguments
The Arguments that this Double expects
71 72 73 74 |
# File 'lib/rr/double.rb', line 71 def expected_arguments verify_argument_expectation_is_set argument_expectation.expected_arguments end |
- (Object) formatted_name
81 82 83 |
# File 'lib/rr/double.rb', line 81 def formatted_name self.class.formatted_name(method_name, expected_arguments) end |
- (Boolean) implementation_is_original_method?
93 94 95 |
# File 'lib/rr/double.rb', line 93 def implementation_is_original_method? definition.implementation_is_original_method? end |
- (Object) method_call(args)
85 86 87 88 89 90 91 |
# File 'lib/rr/double.rb', line 85 def method_call(args) if verbose? puts Double.formatted_name(method_name, args) end times_called_expectation.attempt if definition.times_matcher space.verify_ordered_double(self) if ordered? end |
- (Object) method_name
The method name that this Double is attatched to
66 67 68 |
# File 'lib/rr/double.rb', line 66 def method_name double_injection.method_name end |
- (Boolean) terminal?
60 61 62 63 |
# File 'lib/rr/double.rb', line 60 def terminal? verify_times_matcher_is_set times_called_expectation.terminal? end |
- (Object) times_matcher
The TimesCalledMatcher for the TimesCalledExpectation
77 78 79 |
# File 'lib/rr/double.rb', line 77 def times_matcher definition.times_matcher end |
- (Object) verify
Double#verify verifies the the TimesCalledExpectation is satisfied for this double. A TimesCalledError is raised if the TimesCalledExpectation is not met.
54 55 56 57 58 |
# File 'lib/rr/double.rb', line 54 def verify verify_times_matcher_is_set times_called_expectation.verify! true end |
- (Boolean) wildcard_match?(*arguments)
Double#wildcard_match? returns true when the passed in arguments wildcard match the ArgumentEqualityExpectation arguments.
40 41 42 |
# File 'lib/rr/double.rb', line 40 def wildcard_match?(*arguments) definition.wildcard_match?(*arguments) end |