Sha256: 8e98ea75d541ef3186d8a118b8592742b01c6faaf87c234bcc8ffb64747f2c6c

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

require 'hallmonitor/outputters/statsd_outputter'

module Hallmonitor
  module Outputters
    RSpec.describe StatsdOutputter do
      let(:statsd_client) { instance_double(Statsd) }
      let(:prefix) { 'test' }
      let(:outputter) { described_class.new(prefix) }

      before do
        allow(statsd_client).to receive(:namespace=)
        allow(Statsd).to receive(:new).and_return(statsd_client)
      end

      it 'can be instantiated' do
        expect { outputter }.to_not raise_error
      end

      context '#process' do
        let(:event_name) { 'foo.bar.baz' }
        context 'with an event' do
          let(:event) { Event.new(event_name) }

          it 'sends the event to statsd' do
            expect(statsd_client).to receive(:count).with(event_name, event.count)
            outputter.process(event)
          end

          context 'that has multiple values' do
            let(:values) { { foo: 1, bar: 2 } }
            let(:event) { Event.new(event_name, count: values) }
            it 'sends multiple events to statsd' do
              expect(statsd_client).to receive(:count).with("#{event_name}.foo", event.count[:foo])
              expect(statsd_client).to receive(:count).with("#{event_name}.bar", event.count[:bar])
              outputter.process(event)
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hallmonitor-5.2.0 spec/hallmonitor/outputters/statsd_outputter_spec.rb
hallmonitor-5.1.0 spec/hallmonitor/outputters/statsd_outputter_spec.rb
hallmonitor-5.0.0 spec/hallmonitor/outputters/statsd_outputter_spec.rb
hallmonitor-4.2.0 spec/hallmonitor/outputters/statsd_outputter_spec.rb
hallmonitor-4.1.0 spec/hallmonitor/outputters/statsd_outputter_spec.rb
hallmonitor-4.0.0 spec/hallmonitor/outputters/statsd_outputter_spec.rb
hallmonitor-3.0.0 spec/hallmonitor/outputters/statsd_outputter_spec.rb
hallmonitor-2.0.0 spec/hallmonitor/outputters/statsd_outputter_spec.rb