A sender that just enqueues events and then lets you make assertions about the kinds of events that were sent.
The Array of events which were queued.
Create a new testing sender.
# File lib/observability/sender/testing.rb, line 19
def initialize( * )
@enqueued_events = []
end
Sender API – add the specified events
to the queue.
# File lib/observability/sender/testing.rb, line 35
def enqueue( *events )
@enqueued_events.concat( events )
end
Returns true
if at least one event of the specified type
was enqueued.
# File lib/observability/sender/testing.rb, line 49
def event_was_sent?( type )
return !self.find_events( type ).empty?
end
Return any enqueued events that are of the specified type
.
# File lib/observability/sender/testing.rb, line 41
def find_events( type )
return @enqueued_events.find_all do |event|
event.type == type
end
end
No-ops; there is no sending thread, so nothing to start/stop.
# File lib/observability/sender/testing.rb, line 30
def start( * ); end
# File lib/observability/sender/testing.rb, line 31
def stop( * ); end