Sha256: b2f487b262ec5602fbee63a967939e6c3ca385dfe4d01c594031227750c338a6

Contents?: true

Size: 1.43 KB

Versions: 10

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Mongoid do

  describe ".configure" do

    context "when no block supplied" do

      it "returns the config singleton" do
        expect(Mongoid.configure).to eq(Mongoid::Config)
      end
    end

    context "when a block is supplied" do

      before do
        Mongoid.configure do |config|
          config.preload_models = true
        end
      end

      after do
        Mongoid.configure do |config|
          config.preload_models = false
        end
      end

      it "sets the values on the config instance" do
        expect(Mongoid.preload_models).to be true
      end
    end
  end

  describe ".default_client" do

    it "returns the default client" do
      expect(Mongoid.default_client).to eq(Mongoid::Clients.default)
    end
  end

  describe ".disconnect_clients" do

    let(:clients) do
      Mongoid::Clients.clients.values
    end

    before do
      Band.all.entries
    end

    it "disconnects from all active clients" do
      clients.each do |client|
        expect(client.cluster).to receive(:disconnect!).and_call_original
      end
      Mongoid.disconnect_clients
    end
  end

  describe ".client" do

    it "returns the named client" do
      expect(Mongoid.client(:default)).to eq(Mongoid::Clients.default)
    end
  end

  describe ".models" do

    it "returns the list of known models" do
      expect(Mongoid.models).to include(Band)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mongoid-8.0.4 spec/mongoid_spec.rb
mongoid-8.0.3 spec/mongoid_spec.rb
mongoid-7.5.2 spec/mongoid_spec.rb
mongoid-8.0.2 spec/mongoid_spec.rb
mongoid-7.5.1 spec/mongoid_spec.rb
mongoid-7.4.3 spec/mongoid_spec.rb
mongoid-8.0.1 spec/mongoid_spec.rb
mongoid-7.5.0 spec/mongoid_spec.rb
mongoid-7.4.1 spec/mongoid_spec.rb
mongoid-7.4.0 spec/mongoid_spec.rb