class Observability::Sender::Testing

A sender that just enqueues events and then lets you make assertions about the kinds of events that were sent.

Attributes

enqueued_events[R]

The Array of events which were queued.

Public Class Methods

new( * ) click to toggle source

Create a new testing sender.

# File lib/observability/sender/testing.rb, line 19
def initialize( * )
        @enqueued_events = []
end

Public Instance Methods

enqueue( *events ) click to toggle source

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
event_was_sent?( type ) click to toggle source

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
find_events( type ) click to toggle source

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
start( * ) click to toggle source

No-ops; there is no sending thread, so nothing to start/stop.

# File lib/observability/sender/testing.rb, line 30
def start( * ); end
stop( * ) click to toggle source
# File lib/observability/sender/testing.rb, line 31
def stop( * ); end