Sha256: 7c2a5050f02683c4a1148c65495d36ec011341fe26acc6b4d3503830c6318f0f

Contents?: true

Size: 975 Bytes

Versions: 13

Compression:

Stored size: 975 Bytes

Contents

require 'spec_helper'

describe Datadog::Notifications do

  subject { described_class.instance }
  after   { ActiveSupport::Notifications.unsubscribe(subscription) }

  let!(:subscription) do
    subject.subscribe("mock.perform") do |reporter, event|
      status = event.payload[:status]
      method = event.payload[:method]
      tags   = ["status:#{status}", "method:#{method}"]

      reporter.batch do
        reporter.increment "web.render", tags: tags
        reporter.timing "web.render.time", event.duration, tags: tags
      end
    end
  end

  it 'should have a reporter' do
    expect(subject.send(:reporter)).to be_instance_of(Mock::Reporter)
  end

  it 'should subscribe and report' do
    Mock::Instrumentable.new(method: 'GET').perform
    expect(buffered).to eq([
      "web.render:1|c|#custom:tag,env:test,host:test.host,status:200,method:GET",
      "web.render.time:333|ms|#custom:tag,env:test,host:test.host,status:200,method:GET",
    ])
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
datadog-notifications-0.5.0 spec/datadog/notifications_spec.rb
datadog-notifications-0.4.9 spec/datadog/notifications_spec.rb
datadog-notifications-0.4.8 spec/datadog/notifications_spec.rb
datadog-notifications-0.4.7 spec/datadog/notifications_spec.rb
datadog-notifications-0.4.6 spec/datadog/notifications_spec.rb
datadog-notifications-0.4.5 spec/datadog/notifications_spec.rb
datadog-notifications-0.4.4 spec/datadog/notifications_spec.rb
datadog-notifications-0.4.3 spec/datadog/notifications_spec.rb
datadog-notifications-0.4.2 spec/datadog/notifications_spec.rb
datadog-notifications-0.4.1 spec/datadog/notifications_spec.rb
datadog-notifications-0.4.0 spec/datadog/notifications_spec.rb
datadog-notifications-0.3.1 spec/datadog/notifications_spec.rb
datadog-notifications-0.3.0 spec/datadog/notifications_spec.rb