Class: Mocha::API::HaveReceived
Overview
:nodoc:
Instance Method Summary collapse
- #failure_message ⇒ Object
-
#initialize(expected_method_name) ⇒ HaveReceived
constructor
A new instance of HaveReceived.
- #matches?(mock) ⇒ Boolean
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(expected_method_name) ⇒ HaveReceived
Returns a new instance of 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 @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 |