-
-
Notifications
You must be signed in to change notification settings - Fork 356
/
expectation_chain.rb
47 lines (39 loc) · 1.2 KB
/
expectation_chain.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module RSpec
module Mocks
module AnyInstance
# @api private
class ExpectationChain < Chain
def expectation_fulfilled?
@expectation_fulfilled || constrained_to_any_of?(:never, :any_number_of_times)
end
def initialize(*args, &block)
@expectation_fulfilled = false
super
end
private
def verify_invocation_order(rspec_method_name, *args, &block)
end
end
# @api private
class PositiveExpectationChain < ExpectationChain
private
def create_message_expectation_on(instance)
proxy = ::RSpec::Mocks.proxy_for(instance)
expected_from = IGNORED_BACKTRACE_LINE
me = proxy.add_message_expectation(expected_from, *@expectation_args, &@expectation_block)
if RSpec::Mocks.configuration.yield_instance_from_any_instance_implementation_blocks
me.and_yield_receiver_to_implementation
end
me
end
def invocation_order
@invocation_order ||= {
:with => [nil],
:and_return => [:with, nil],
:and_raise => [:with, nil]
}
end
end
end
end
end