Class: RSpec::Mocks::LiveMessageExpectation
- Inherits:
-
MessageExpectation
- Object
- MessageExpectation
- RSpec::Mocks::LiveMessageExpectation
- Defined in:
- lib/rspec/mocks-call-through.rb
Instance Attribute Summary collapse
-
#method_double ⇒ Object
readonly
Returns the value of attribute method_double.
Instance Method Summary collapse
- #and_call_through ⇒ Object
-
#initialize(method_double, *args, &block) ⇒ LiveMessageExpectation
constructor
A new instance of LiveMessageExpectation.
- #invoke_return_block(*args, &block) ⇒ Object
Constructor Details
#initialize(method_double, *args, &block) ⇒ LiveMessageExpectation
Returns a new instance of LiveMessageExpectation.
35 36 37 38 |
# File 'lib/rspec/mocks-call-through.rb', line 35 def initialize(method_double, *args, &block) @method_double = method_double super(*args, &block) end |
Instance Attribute Details
#method_double ⇒ Object (readonly)
Returns the value of attribute method_double.
33 34 35 |
# File 'lib/rspec/mocks-call-through.rb', line 33 def method_double @method_double end |
Instance Method Details
#and_call_through ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rspec/mocks-call-through.rb', line 45 def and_call_through and_return { |*args| method_name = @method_double.obfuscate(@method_double.method_name) object = @method_double.object method = object.method(method_name) block = args.pop if args.last.kind_of?(Proc) && args.last.tainted? object.send(method_name, *args, &block) } end |
#invoke_return_block(*args, &block) ⇒ Object
40 41 42 43 |
# File 'lib/rspec/mocks-call-through.rb', line 40 def invoke_return_block(*args, &block) block.taint if block super(*args, &block) end |