Class: Mocha::API::HaveReceived
- Inherits:
-
Object
- Object
- Mocha::API::HaveReceived
show all
- Defined in:
- lib/bourne/api.rb
Overview
Instance Method Summary
(collapse)
Constructor Details
- (HaveReceived) initialize(expected_method_name)
A new instance of HaveReceived
23
24
25
26
|
# File 'lib/bourne/api.rb', line 23
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
- (Object) method_missing(method, *args, &block)
28
29
30
31
|
# File 'lib/bourne/api.rb', line 28
def method_missing(method, *args, &block)
@expectations << [method, args, block]
self
end
|
Instance Method Details
- (Boolean) does_not_match?(mock)
48
49
50
51
|
# File 'lib/bourne/api.rb', line 48
def does_not_match?(mock)
raise InvalidHaveReceived.new("should_not have_received(:#{@expected_method_name}) is invalid, please use" +
" should have_received(:#{@expected_method_name}).never")
end
|
- (Object) failure_message
53
54
55
|
# File 'lib/bourne/api.rb', line 53
def failure_message
@expectation.mocha_inspect
end
|
- (Boolean) matches?(mock)
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/bourne/api.rb', line 33
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
|