Sha256: 369d4c6a66befa67de54b376b3f24c5ae68ab451ce4521446989f8489d45ff86

Contents?: true

Size: 759 Bytes

Versions: 4

Compression:

Stored size: 759 Bytes

Contents

require 'libhoney/client'
require 'libhoney/mock_transmission'

module Libhoney

  # A client with the network stubbed out for testing purposes. Does not
  # actually send any events to Honeycomb; instead, records events for later
  # inspection.
  #
  # @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.
  class TestClient < Client
    def initialize(*args, **kwargs)
      super(*args, transmission: MockTransmissionClient.new, **kwargs)
    end

    # @return [Array<Event>] the recorded events
    def events
      @tx.events
    end

    # Discards the recorded events
    def reset
      @tx.reset
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
libhoney-1.10.1 lib/libhoney/test_client.rb
libhoney-1.10.0 lib/libhoney/test_client.rb
libhoney-1.9.0 lib/libhoney/test_client.rb
libhoney-1.8.1 lib/libhoney/test_client.rb