Sha256: 60bffa09e9876e96acbf3eaecce5bbb078cb66776986c76754ffaf1bd819fd72

Contents?: true

Size: 738 Bytes

Versions: 24

Compression:

Stored size: 738 Bytes

Contents

# frozen_string_literal: true

module Mongoid
  module Expectations

    def connection_class
      if defined?(Mongo::Server::ConnectionBase)
        Mongo::Server::ConnectionBase
      else
        # Pre-2.8 drivers
        Mongo::Server::Connection
      end
    end

    def expect_query(number)
      rv = nil
      RSpec::Mocks.with_temporary_scope do
        if number > 0
          expect_any_instance_of(connection_class).to receive(:command_started).exactly(number).times.and_call_original
        else
          expect_any_instance_of(connection_class).not_to receive(:command_started)
        end
        rv = yield
      end
      rv
    end

    def expect_no_queries(&block)
      expect_query(0, &block)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
mongoid-8.1.7 spec/support/expectations.rb
mongoid-8.1.6 spec/support/expectations.rb
mongoid-8.0.8 spec/support/expectations.rb
mongoid-8.1.5 spec/support/expectations.rb
mongoid-8.1.4 spec/support/expectations.rb
mongoid-8.0.7 spec/support/expectations.rb
mongoid-8.1.3 spec/support/expectations.rb
mongoid-8.1.2 spec/support/expectations.rb
mongoid-8.0.6 spec/support/expectations.rb
mongoid-7.5.4 spec/support/expectations.rb
mongoid-8.1.1 spec/support/expectations.rb
mongoid-8.0.5 spec/support/expectations.rb
mongoid-8.1.0 spec/support/expectations.rb
mongoid-7.5.3 spec/support/expectations.rb
mongoid-8.0.4 spec/support/expectations.rb
mongoid-8.0.3 spec/support/expectations.rb
mongoid-7.5.2 spec/support/expectations.rb
mongoid-8.0.2 spec/support/expectations.rb
mongoid-7.5.1 spec/support/expectations.rb
mongoid-7.4.3 spec/support/expectations.rb