Sha256: 0eba2a4a9df972f863d56ffc306d62d2be79377cb465e72c33106c419de1d76a

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

require 'airbrake/rails/excon_subscriber'

RSpec.describe Airbrake::Rails::Excon do
  after { Airbrake::Rack::RequestStore.clear }

  let(:event) { double(Airbrake::Rails::Event) }

  before do
    allow(Airbrake::Rails::Event).to receive(:new).and_return(event)
  end

  context "when there are no routes in the request store" do
    it "doesn't notify requests" do
      expect(Airbrake).not_to receive(:notify_performance_breakdown)
      subject.call([])
    end
  end

  context "when there's a route in the request store" do
    let(:route) { Airbrake::Rack::RequestStore[:routes]['/test-route'] }

    before do
      Airbrake::Rack::RequestStore[:routes] = {
        '/test-route' => { groups: {} }
      }

      expect(event).to receive(:duration).and_return(0.1)
    end

    it "sets http group value of that route" do
      subject.call([])
      expect(route[:groups][:http]).to eq(0.1)
    end

    context "and when the subscriber is called multiple times" do
      before { expect(event).to receive(:duration).and_return(0.1) }

      it "increments http group value of that route" do
        subject.call([])
        subject.call([])

        expect(route[:groups][:http]).to eq(0.2)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
airbrake-9.2.1 spec/unit/rails/excon_spec.rb
airbrake-9.2.0 spec/unit/rails/excon_spec.rb