Sha256: 553fade46bac213790d677b7ceafa28bdb2bf3b1ae7f70a69e7b53f1b2276056

Contents?: true

Size: 1.16 KB

Versions: 308

Compression:

Stored size: 1.16 KB

Contents

describe Appsignal::Hooks::MongoRubyDriverHook do
  require "appsignal/integrations/mongo_ruby_driver"

  context "with mongo ruby driver" do
    let(:subscriber) { Appsignal::Hooks::MongoMonitorSubscriber.new }
    before { allow(Appsignal::Hooks::MongoMonitorSubscriber).to receive(:new).and_return(subscriber) }

    before(:context) do
      module Mongo
        module Monitoring
          COMMAND = "command".freeze

          class Global
            def subscribe
            end
          end
        end
      end
    end
    after(:context) { Object.send(:remove_const, :Mongo) }

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

      it { is_expected.to be_truthy }
    end

    it "adds a subscriber to Mongo::Monitoring" do
      expect(Mongo::Monitoring::Global).to receive(:subscribe)
        .with("command", subscriber)
        .at_least(:once)

      Appsignal::Hooks::MongoRubyDriverHook.new.install
    end
  end

  context "without mongo ruby driver" do
    describe "#dependencies_present?" do
      subject { described_class.new.dependencies_present? }

      it { is_expected.to be_falsy }
    end
  end
end

Version data entries

308 entries across 308 versions & 1 rubygems

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