Class: Libhoney::MockTransmissionClient

Inherits:
Object
  • Object
show all
Defined in:
lib/libhoney/mock_transmission.rb

Overview

Note:

This class is intended for use in tests, for example if you want to verify what events your instrumented code is sending. Use in production is not recommended.

For testing use: a mock version of TransmissionClient that retains all events in an in-memory queue for inspection (and does not send them to Honeycomb, or perform any network activity).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**_) ⇒ MockTransmissionClient

Returns a new instance of MockTransmissionClient.



10
11
12
# File 'lib/libhoney/mock_transmission.rb', line 10

def initialize(**_)
  reset
end

Instance Attribute Details

#eventsArray<Event> (readonly)

Returns the recorded events.

Returns:

  • (Array<Event>)

    the recorded events



15
16
17
# File 'lib/libhoney/mock_transmission.rb', line 15

def events
  @events
end

Instance Method Details

#add(event) ⇒ Object

Records an event



18
19
20
# File 'lib/libhoney/mock_transmission.rb', line 18

def add(event)
  @events.push(event)
end

#close(drain) ⇒ Object

Does nothing.



23
# File 'lib/libhoney/mock_transmission.rb', line 23

def close(drain); end

#resetObject

Discards the recorded events



26
27
28
# File 'lib/libhoney/mock_transmission.rb', line 26

def reset
  @events = []
end