Class: Mocha::API::HaveReceived
Overview
Instance Method Summary
collapse
Constructor Details
#initialize(expected_method_name) ⇒ HaveReceived
166
167
168
169
|
# File 'lib/mocha/api.rb', line 166
def initialize(expected_method_name)
@expected_method_name = expected_method_name
@expectations = []
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
171
172
173
174
|
# File 'lib/mocha/api.rb', line 171
def method_missing(method, *args, &block)
@expectations << [method, args, block]
self
end
|
Instance Method Details
#failure_message ⇒ Object
191
192
193
|
# File 'lib/mocha/api.rb', line 191
def failure_message
@expectation.mocha_inspect
end
|
#matches?(mock) ⇒ Boolean
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/mocha/api.rb', line 176
def matches?(mock)
if mock.respond_to?(:mocha)
@mock = mock.mocha
else
@mock = mock
end
@expectation = Expectation.new(@mock, @expected_method_name)
@expectations.each do |method, args, block|
@expectation.send(method, *args, &block)
end
@expectation.invocation_count = invocation_count
@expectation.verified?
end
|