Sha256: fb96508cf6e4842def7663a2e20aa8437ce2fed93881b35e212e59909066a2d5

Contents?: true

Size: 1.92 KB

Versions: 92

Compression:

Stored size: 1.92 KB

Contents

describe Appsignal::Hooks::ExconHook do
  before :context do
    start_agent
  end

  context "with Excon" do
    before(:context) do
      class Excon
        def self.defaults
          @defaults ||= {}
        end
      end
      Appsignal::Hooks::ExconHook.new.install
    end
    after(:context) { Object.send(:remove_const, :Excon) }

    describe "#dependencies_present?" do
      subject { described_class.new.dependencies_present? }

      it { is_expected.to be_truthy }
    end

    describe "#install" do
      it "adds the AppSignal instrumentor to Excon" do
        expect(Excon.defaults[:instrumentor]).to eql(Appsignal::Integrations::ExconIntegration)
      end
    end

    describe "instrumentation" do
      let!(:transaction) do
        Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
      end
      around { |example| keep_transactions { example.run } }

      it "instruments a http request" do
        data = {
          :host => "www.google.com",
          :method => :get,
          :scheme => "http"
        }
        Excon.defaults[:instrumentor].instrument("excon.request", data) {}

        expect(transaction.to_h["events"]).to include(
          hash_including(
            "name" => "request.excon",
            "title" => "GET http://www.google.com",
            "body" => ""
          )
        )
      end

      it "instruments a http response" do
        data = { :host => "www.google.com" }
        Excon.defaults[:instrumentor].instrument("excon.response", data) {}

        expect(transaction.to_h["events"]).to include(
          hash_including(
            "name" => "response.excon",
            "title" => "www.google.com",
            "body" => ""
          )
        )
      end
    end
  end

  context "without Excon" do
    describe "#dependencies_present?" do
      subject { described_class.new.dependencies_present? }

      it { is_expected.to be_falsy }
    end
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
appsignal-3.3.11-java spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.11 spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.4.0-java spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.4.0 spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.10-java spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.10 spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.9-java spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.9 spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.8-java spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.8 spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.7-java spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.7 spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.6-java spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.6 spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.5-java spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.5 spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.4-java spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.4 spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.3-java spec/lib/appsignal/hooks/excon_spec.rb
appsignal-3.3.3 spec/lib/appsignal/hooks/excon_spec.rb