Sha256: fcb93433e6f0afb95a6b111828c20c657cb5303f86c36ccb39b2794c8245c6f1

Contents?: true

Size: 1.14 KB

Versions: 43

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

# This test is for checking connectivity of the test client to the
# test cluster. In other words, it is a test that the test suite is
# configured correctly.
describe 'Client connectivity' do
  shared_examples_for 'is correctly configured' do
    it 'is configured with the correct database' do
      expect(client.options[:database]).to eq(SpecConfig.instance.test_db)
    end

    it 'has correct database in the cluster' do
      expect(client.cluster.options[:database]).to eq(SpecConfig.instance.test_db)
    end
  end

  context 'no auth' do
    let(:client) { ClientRegistry.instance.global_client('basic') }

    it_behaves_like 'is correctly configured'

    it 'connects and is usable' do
      resp = client.database.command(ismaster: 1)
      expect(resp).to be_a(Mongo::Operation::Result)
    end
  end

  context 'with auth' do
    let(:client) { ClientRegistry.instance.global_client('authorized') }

    it_behaves_like 'is correctly configured'

    it 'connects and is usable' do
      client['connectivity_spec'].insert_one(foo: 1)
      expect(client['connectivity_spec'].find(foo: 1).first['foo']).to eq(1)
    end
  end
end

Version data entries

43 entries across 43 versions & 2 rubygems

Version Path
mongo-2.13.3 spec/integration/client_connectivity_spec.rb
mongo-2.14.1 spec/integration/client_connectivity_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongo-2.8.0/spec/integration/client_connectivity_spec.rb
mongo-2.15.0.alpha spec/integration/client_connectivity_spec.rb
mongo-2.13.2 spec/integration/client_connectivity_spec.rb
mongo-2.14.0 spec/integration/client_connectivity_spec.rb
mongo-2.14.0.rc1 spec/integration/client_connectivity_spec.rb
mongo-2.13.1 spec/integration/client_connectivity_spec.rb
mongo-2.12.4 spec/integration/client_connectivity_spec.rb
mongo-2.11.6 spec/integration/client_connectivity_spec.rb
mongo-2.13.0 spec/integration/client_connectivity_spec.rb
mongo-2.12.3 spec/integration/client_connectivity_spec.rb
mongo-2.13.0.rc1 spec/integration/client_connectivity_spec.rb
mongo-2.12.2 spec/integration/client_connectivity_spec.rb
mongo-2.10.5 spec/integration/client_connectivity_spec.rb
mongo-2.11.5 spec/integration/client_connectivity_spec.rb
mongo-2.13.0.beta1 spec/integration/client_connectivity_spec.rb
mongo-2.12.1 spec/integration/client_connectivity_spec.rb
mongo-2.12.0.rc0 spec/integration/client_connectivity_spec.rb
mongo-2.11.4 spec/integration/client_connectivity_spec.rb