Class: Message::Recorder::ChainingMock
- Defined in:
- lib/message-recorder/chaining_mock.rb
Overview
ChainingMock is the mock object returned by the Message::Recorder#record method.
Instance Method Summary collapse
-
#__branch__(&block) ⇒ Object
(also: #with_results, #with_result, #branch)
when a block is passed to branch it will create a separate call chain for each method call.
-
#initialize(recorder, collector) ⇒ ChainingMock
constructor
:nodoc:.
-
#method_missing(m, *args, &block) ⇒ Object
:nodoc:.
Constructor Details
#initialize(recorder, collector) ⇒ ChainingMock
:nodoc:
27 28 29 30 |
# File 'lib/message-recorder/chaining_mock.rb', line 27 def initialize(recorder, collector) # :nodoc: @recorder = recorder @collector = collector end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
:nodoc:
32 33 34 35 36 37 38 |
# File 'lib/message-recorder/chaining_mock.rb', line 32 def method_missing(m, *args, &block) # :nodoc: = ::Message::Recorder::Message.new(m, args, block) @recorder.filter_before_chain() @collector.record() @recorder.filter_after_chain() return self end |
Instance Method Details
#__branch__(&block) ⇒ Object Also known as: with_results, with_result, branch
when a block is passed to branch it will create a separate call chain for each method call. recorder.record.branch do hello bye end recorder.send_to subject is the same as recorder.record.hello recorder.send_to subject
recorder.record.bye
recorder.send_to subject
52 53 54 |
# File 'lib/message-recorder/chaining_mock.rb', line 52 def __branch__(&block) Message::Recorder::BranchingMock.new(@recorder, @collector).__branch__(&block) end |