Sha256: 85a74d555c9dfd3006ba5526fe5094653fff9fc202960355fef8a57b96724468

Contents?: true

Size: 1.21 KB

Versions: 148

Compression:

Stored size: 1.21 KB

Contents

describe Appsignal::Hooks::SequelHook do
  if DependencyHelper.sequel_present?
    let(:db) do
      if DependencyHelper.running_jruby?
        Sequel.connect("jdbc:sqlite::memory:")
      else
        Sequel.sqlite
      end
    end

    before :context do
      start_agent
    end

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

      it { is_expected.to be_truthy }
    end

    context "with a transaction" do
      let(:transaction) { Appsignal::Transaction.current }
      before do
        Appsignal::Transaction.create("uuid", Appsignal::Transaction::HTTP_REQUEST, "test")
        db.logger = Logger.new($stdout) # To test #log_duration call
      end

      it "should instrument queries" do
        expect(transaction).to receive(:start_event).at_least(:once)
        expect(transaction).to receive(:finish_event)
          .at_least(:once)
          .with("sql.sequel", nil, kind_of(String), 1)

        expect(db).to receive(:log_duration).at_least(:once)

        db["SELECT 1"].all.to_a
      end
    end
  else
    describe "#dependencies_present?" do
      subject { described_class.new.dependencies_present? }

      it { is_expected.to be_falsy }
    end
  end
end

Version data entries

148 entries across 148 versions & 1 rubygems

Version Path
appsignal-3.11.0-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.11.0 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.10.0-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.10.0 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.9.3-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.9.3 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.9.2-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.9.2 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.9.1-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.9.1 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.9.0-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.9.0 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.8.1-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.8.1 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.8.0-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.8.0 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.7.6-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.7.6 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.7.2-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.7.2 spec/lib/appsignal/hooks/sequel_spec.rb