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.1.2-java spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.1.2 spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.1.1-java spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.1.1 spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.1.0-java spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.1.0 spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.27-java spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.27 spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.26-java spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.26 spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.25-java spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.25 spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.24-java spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.24 spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.23-java spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.23 spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.22-java spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.22 spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.21-java spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
appsignal-3.0.21 spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb