Class: AncientMock::ExpectationDefinition
- Inherits:
-
Object
- Object
- AncientMock::ExpectationDefinition
- Defined in:
- lib/ancient_mock.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#return_value ⇒ Object
readonly
Returns the value of attribute return_value.
Instance Method Summary collapse
- #and_return(return_value) ⇒ Object
- #call ⇒ Object
-
#initialize(message) ⇒ ExpectationDefinition
constructor
A new instance of ExpectationDefinition.
- #matches?(message, *arguments) ⇒ Boolean
- #verify ⇒ Object
- #with(*arguments) ⇒ Object
Constructor Details
#initialize(message) ⇒ ExpectationDefinition
Returns a new instance of ExpectationDefinition.
77 78 79 80 |
# File 'lib/ancient_mock.rb', line 77 def initialize() @message = @invocation_count = 0 end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
75 76 77 |
# File 'lib/ancient_mock.rb', line 75 def @message end |
#return_value ⇒ Object (readonly)
Returns the value of attribute return_value.
75 76 77 |
# File 'lib/ancient_mock.rb', line 75 def return_value @return_value end |
Instance Method Details
#and_return(return_value) ⇒ Object
82 83 84 85 |
# File 'lib/ancient_mock.rb', line 82 def and_return(return_value) @return_value = return_value self end |
#call ⇒ Object
97 98 99 100 |
# File 'lib/ancient_mock.rb', line 97 def call @invocation_count += 1 @return_value end |
#matches?(message, *arguments) ⇒ Boolean
92 93 94 95 |
# File 'lib/ancient_mock.rb', line 92 def matches?(, *arguments) == @message && (@arguments.nil? || arguments == @arguments) end |
#verify ⇒ Object
102 103 104 105 106 |
# File 'lib/ancient_mock.rb', line 102 def verify if @invocation_count != 1 raise ExpectationNotSatisfied end end |
#with(*arguments) ⇒ Object
87 88 89 90 |
# File 'lib/ancient_mock.rb', line 87 def with(*arguments) @arguments = arguments self end |