Class: Libhoney::TestClient

Inherits:
Client
  • Object
show all
Defined in:
lib/libhoney/test_client.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.

A client with the network stubbed out for testing purposes. Does not actually send any events to Honeycomb; instead, records events for later inspection.

Constant Summary

Constants inherited from Client

Client::API_HOST, Client::DEFAULT_DATASET

Instance Attribute Summary

Attributes inherited from Client

#block_on_responses, #block_on_send, #max_batch_size, #max_concurrent_batches, #pending_work_capacity, #responses, #send_frequency

Instance Method Summary collapse

Methods inherited from Client

#add, #add_dynamic_field, #add_field, #close, #send_dropped_response, #send_event, #send_now, #should_drop

Constructor Details

#initialize(*args, **kwargs) ⇒ TestClient

Returns a new instance of TestClient.



13
14
15
# File 'lib/libhoney/test_client.rb', line 13

def initialize(*args, **kwargs)
  super(*args, transmission: MockTransmissionClient.new, **kwargs)
end

Instance Method Details

#eventsArray<Event>

Returns the recorded events.

Returns:

  • (Array<Event>)

    the recorded events



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

def events
  @transmission.events
end

#resetObject

Discards the recorded events



23
24
25
# File 'lib/libhoney/test_client.rb', line 23

def reset
  @transmission.reset
end