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.10.4 spec/integration/client_connectivity_spec.rb
mongo-2.11.3 spec/integration/client_connectivity_spec.rb
mongo-2.11.2 spec/integration/client_connectivity_spec.rb
mongo-2.11.1 spec/integration/client_connectivity_spec.rb
mongo-2.10.3 spec/integration/client_connectivity_spec.rb
mongo-2.11.0 spec/integration/client_connectivity_spec.rb
mongo-2.9.2 spec/integration/client_connectivity_spec.rb
mongo-2.10.2 spec/integration/client_connectivity_spec.rb
mongo-2.11.0.rc0 spec/integration/client_connectivity_spec.rb
mongo-2.10.1 spec/integration/client_connectivity_spec.rb
mongo-2.10.0 spec/integration/client_connectivity_spec.rb
mongo-2.9.1 spec/integration/client_connectivity_spec.rb
mongo-2.10.0.rc0 spec/integration/client_connectivity_spec.rb
mongo-2.9.1.rc0 spec/integration/client_connectivity_spec.rb
mongo-2.9.0 spec/integration/client_connectivity_spec.rb
mongo-2.9.0.rc1 spec/integration/client_connectivity_spec.rb
mongo-2.9.0.rc0 spec/integration/client_connectivity_spec.rb
mongo-2.8.0 spec/integration/client_connectivity_spec.rb
mongo-2.7.2 spec/integration/client_connectivity_spec.rb
mongo-2.8.0.rc0 spec/integration/client_connectivity_spec.rb