Testing

class
Superclass
Observability::Sender
Extended With
Loggability

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

anchor
new( * )

Create a new testing sender.

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

Public Instance Methods

anchor
enqueue( *events )

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
anchor
event_was_sent?( type )

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
anchor
find_events( type )

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
anchor
start( * )

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

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