Sha256: 08c98a885ac70f021f2bdaadf5a6bca2c6f97cac0ecc570ac0e93b871a2c4c38

Contents?: true

Size: 1.2 KB

Versions: 222

Compression:

Stored size: 1.2 KB

Contents

describe Appsignal::Hooks::SequelHook do
  if DependencyHelper.sequel_present?
    let(:db) do
      if Appsignal::System.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

222 entries across 222 versions & 1 rubygems

Version Path
appsignal-3.0.18-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.18 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.17-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.17 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.16-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.16 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.15-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.15 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.14-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.14 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.13-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.13 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.12-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.12 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.11-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.11 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.10-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-3.0.10 spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-2.11.10-java spec/lib/appsignal/hooks/sequel_spec.rb
appsignal-2.11.10 spec/lib/appsignal/hooks/sequel_spec.rb