Class: Observability::Sender::Testing
- Inherits:
-
Observability::Sender
- Object
- Observability::Sender
- Observability::Sender::Testing
- Extended by:
- Loggability
- Defined in:
- lib/observability/sender/testing.rb
Overview
A sender that just enqueues events and then lets you make assertions about the kinds of events that were sent.
Instance Attribute Summary collapse
-
#enqueued_events ⇒ Object
readonly
The Array of events which were queued.
Attributes inherited from Observability::Sender
Instance Method Summary collapse
-
#enqueue(*events) ⇒ Object
Sender API – add the specified
eventsto the queue. -
#event_was_sent?(type) ⇒ Boolean
Returns
trueif at least one event of the specifiedtypewas enqueued. -
#find_events(type) ⇒ Object
Return any enqueued events that are of the specified
type. -
#initialize ⇒ Testing
constructor
Create a new testing sender.
-
#start ⇒ Object
No-ops; there is no sending thread, so nothing to start/stop.
- #stop ⇒ Object
Methods inherited from Observability::Sender
Constructor Details
#initialize ⇒ Testing
Create a new testing sender.
20 21 22 |
# File 'lib/observability/sender/testing.rb', line 20 def initialize( * ) @enqueued_events = [] end |
Instance Attribute Details
#enqueued_events ⇒ Object (readonly)
The Array of events which were queued.
27 28 29 |
# File 'lib/observability/sender/testing.rb', line 27 def enqueued_events @enqueued_events end |
Instance Method Details
#enqueue(*events) ⇒ Object
Sender API – add the specified events to the queue.
36 37 38 |
# File 'lib/observability/sender/testing.rb', line 36 def enqueue( *events ) @enqueued_events.concat( events ) end |
#event_was_sent?(type) ⇒ Boolean
Returns true if at least one event of the specified type was enqueued.
50 51 52 |
# File 'lib/observability/sender/testing.rb', line 50 def event_was_sent?( type ) return !self.find_events( type ).empty? end |
#find_events(type) ⇒ Object
Return any enqueued events that are of the specified type.
42 43 44 45 46 |
# File 'lib/observability/sender/testing.rb', line 42 def find_events( type ) return @enqueued_events.find_all do |event| event.type == type end end |
#start ⇒ Object
No-ops; there is no sending thread, so nothing to start/stop.
31 |
# File 'lib/observability/sender/testing.rb', line 31 def start( * ); end |
#stop ⇒ Object
32 |
# File 'lib/observability/sender/testing.rb', line 32 def stop( * ); end |