Sha256: 4aec323fed9833179d0fa11d0327173b53a7177c4212970f4c83774e262f0bba

Contents?: true

Size: 1.36 KB

Versions: 13

Compression:

Stored size: 1.36 KB

Contents

describe Appsignal::Hooks::ActiveSupportNotificationsHook do
  if active_support_present?
    before :all do
      start_agent
    end
    before do
      Appsignal::Transaction.create('uuid', Appsignal::Transaction::HTTP_REQUEST, 'test')
    end

    let(:notifier) { ActiveSupport::Notifications::Fanout.new }
    let(:instrumenter) { ActiveSupport::Notifications::Instrumenter.new(notifier) }

    its(:dependencies_present?) { should be_true }

    it "should instrument an AS notifications instrument call with a block" do
      expect( Appsignal::Transaction.current ).to receive(:start_event)
        .at_least(:once)
      expect( Appsignal::Transaction.current ).to receive(:finish_event)
        .at_least(:once)
        .with("sql.active_record", nil, 'SQL', 1)

      return_value = instrumenter.instrument('sql.active_record', :sql => 'SQL') do
        'value'
      end

      expect(return_value).to eq 'value'
    end

    it "should not instrument events whose name starts with a bang" do
      expect( Appsignal::Transaction.current ).not_to receive(:start_event)
      expect( Appsignal::Transaction.current ).not_to receive(:finish_event)

      return_value = instrumenter.instrument('!sql.active_record', :sql => 'SQL') do
        'value'
      end

      expect(return_value).to eq 'value'
    end
  else
    its(:dependencies_present?) { should be_false }
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
appsignal-2.0.6 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-2.0.5 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-2.0.5.beta.1 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-2.1.0.alpha.3 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-2.1.0.alpha.2 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-2.1.0.alpha.1 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-2.0.4 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-2.0.3 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-2.0.2 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-2.0.1 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-2.0.0 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-2.0.0.beta.1 spec/lib/appsignal/hooks/active_support_notifications_spec.rb
appsignal-1.4.0.beta.1 spec/lib/appsignal/hooks/active_support_notifications_spec.rb