Class: Mocha::API::HaveReceived
- Inherits:
-
Object
- Object
- Mocha::API::HaveReceived
- Defined in:
- lib/bourne/api.rb
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.
20 21 22 23 |
# File 'lib/bourne/api.rb', line 20 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
25 26 27 28 |
# File 'lib/bourne/api.rb', line 25 def method_missing(method, *args, &block) @expectations << [method, args, block] self end |
Instance Method Details
#failure_message ⇒ Object
45 46 47 |
# File 'lib/bourne/api.rb', line 45 def @expectation.mocha_inspect end |
#matches?(mock) ⇒ Boolean
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bourne/api.rb', line 30 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 |