Class: Daylight::Mock::Recorder
- Inherits:
-
Object
- Object
- Daylight::Mock::Recorder
- Defined in:
- lib/daylight/mock.rb
Overview
Keeps track of all request and response pairs. Stored by action and resource.
Example:
daylight_mock.created(:project).count.should == 3
daylight_mock.last_created(:project).name.should == 'Test Project'
Instance Method Summary collapse
-
#initialize ⇒ Recorder
constructor
A new instance of Recorder.
-
#record(handler) ⇒ Object
Store a Handler in the Recorder.
Constructor Details
#initialize ⇒ Recorder
Returns a new instance of Recorder.
196 197 198 199 200 201 202 203 204 |
# File 'lib/daylight/mock.rb', line 196 def initialize # hashy hash hash @storage = Hash.new do |action_hash, action| action_hash[action] = Hash.new do |handler_hash, handler| handler_hash[handler] = [] end end end |
Instance Method Details
#record(handler) ⇒ Object
Store a Handler in the Recorder
218 219 220 |
# File 'lib/daylight/mock.rb', line 218 def record(handler) @storage[handler.action.to_s][handler.resource.to_s] << handler end |