Class: RSpec::Armour::ExpectationProxy
- Inherits:
-
Object
- Object
- RSpec::Armour::ExpectationProxy
show all
- Defined in:
- lib/rspec/armour/expect_and_call_original.rb
Instance Method Summary
collapse
Constructor Details
#initialize(expectation, target) ⇒ ExpectationProxy
Returns a new instance of ExpectationProxy.
6
7
8
9
|
# File 'lib/rspec/armour/expect_and_call_original.rb', line 6
def initialize(expectation, target)
@expectation = expectation
@target = target
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/rspec/armour/expect_and_call_original.rb', line 36
def method_missing(name, ...)
if @expectation.respond_to?(name)
res = @expectation.public_send(name, ...)
res.equal?(@expectation) ? self : res
else
super
end
end
|
Instance Method Details
#and_call_original ⇒ Object
11
12
13
14
|
# File 'lib/rspec/armour/expect_and_call_original.rb', line 11
def and_call_original(...)
@expectation.and_call_original(...)
self
end
|
#and_raise ⇒ Object
21
22
23
24
|
# File 'lib/rspec/armour/expect_and_call_original.rb', line 21
def and_raise(*)
cleanup
raise MockError, "Cannot call and_raise when using expect_receive_and_call_original"
end
|
#and_return ⇒ Object
16
17
18
19
|
# File 'lib/rspec/armour/expect_and_call_original.rb', line 16
def and_return(*)
cleanup
raise MockError, "Cannot call and_return when using expect_receive_and_call_original"
end
|
#and_throw ⇒ Object
26
27
28
29
|
# File 'lib/rspec/armour/expect_and_call_original.rb', line 26
def and_throw(*)
cleanup
raise MockError, "Cannot call and_throw when using expect_receive_and_call_original"
end
|
#and_yield ⇒ Object
31
32
33
34
|
# File 'lib/rspec/armour/expect_and_call_original.rb', line 31
def and_yield(*)
cleanup
raise MockError, "Cannot call and_yield when using expect_receive_and_call_original"
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
45
46
47
|
# File 'lib/rspec/armour/expect_and_call_original.rb', line 45
def respond_to_missing?(name, include_private = false)
@expectation.respond_to?(name, include_private) || super
end
|