Class: Crabfarm::RSpec::ReducerSpy
- Inherits:
-
Object
- Object
- Crabfarm::RSpec::ReducerSpy
- Defined in:
- lib/crabfarm/rspec/reducer_spy.rb
Defined Under Namespace
Classes: Call
Instance Attribute Summary collapse
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#mock ⇒ Object
readonly
Returns the value of attribute mock.
-
#original ⇒ Object
readonly
Returns the value of attribute original.
Instance Method Summary collapse
-
#initialize(_original) ⇒ ReducerSpy
constructor
A new instance of ReducerSpy.
- #mock_with(_attributes) ⇒ Object
- #params ⇒ Object
- #register_call(_target, _params) ⇒ Object
- #target ⇒ Object
Constructor Details
#initialize(_original) ⇒ ReducerSpy
Returns a new instance of ReducerSpy.
9 10 11 12 13 |
# File 'lib/crabfarm/rspec/reducer_spy.rb', line 9 def initialize(_original) @original = _original @calls = [] @mock = nil end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
7 8 9 |
# File 'lib/crabfarm/rspec/reducer_spy.rb', line 7 def calls @calls end |
#mock ⇒ Object (readonly)
Returns the value of attribute mock.
7 8 9 |
# File 'lib/crabfarm/rspec/reducer_spy.rb', line 7 def mock @mock end |
#original ⇒ Object (readonly)
Returns the value of attribute original.
7 8 9 |
# File 'lib/crabfarm/rspec/reducer_spy.rb', line 7 def original @original end |
Instance Method Details
#mock_with(_attributes) ⇒ Object
29 30 31 32 |
# File 'lib/crabfarm/rspec/reducer_spy.rb', line 29 def mock_with(_attributes) @mock = _attributes self end |
#params ⇒ Object
24 25 26 27 |
# File 'lib/crabfarm/rspec/reducer_spy.rb', line 24 def params raise "'#{@original.to_s}' was not invoked" if calls.size == 0 calls.first.params end |
#register_call(_target, _params) ⇒ Object
15 16 17 |
# File 'lib/crabfarm/rspec/reducer_spy.rb', line 15 def register_call(_target, _params) @calls << Call.new(_target, _params) end |
#target ⇒ Object
19 20 21 22 |
# File 'lib/crabfarm/rspec/reducer_spy.rb', line 19 def target raise "'#{@original.to_s}' was not invoked" if calls.size == 0 calls.first.target end |