Sha256: 4436bb3560d064f095347bc57e652f31b2e060f9ca9024e6114bef05be1683f7

Contents?: true

Size: 1.19 KB

Versions: 18

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

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(ping: 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

18 entries across 18 versions & 1 rubygems

Version Path
mongo-2.16.4 spec/integration/client_connectivity_spec.rb
mongo-2.17.4 spec/integration/client_connectivity_spec.rb
mongo-2.18.3 spec/integration/client_connectivity_spec.rb
mongo-2.18.2 spec/integration/client_connectivity_spec.rb
mongo-2.17.3 spec/integration/client_connectivity_spec.rb
mongo-2.18.1 spec/integration/client_connectivity_spec.rb
mongo-2.18.0 spec/integration/client_connectivity_spec.rb
mongo-2.17.2 spec/integration/client_connectivity_spec.rb
mongo-2.16.3 spec/integration/client_connectivity_spec.rb
mongo-2.18.0.beta1 spec/integration/client_connectivity_spec.rb
mongo-2.16.2 spec/integration/client_connectivity_spec.rb
mongo-2.17.1 spec/integration/client_connectivity_spec.rb
mongo-2.16.1 spec/integration/client_connectivity_spec.rb
mongo-2.17.0 spec/integration/client_connectivity_spec.rb
mongo-2.16.0 spec/integration/client_connectivity_spec.rb
mongo-2.15.1 spec/integration/client_connectivity_spec.rb
mongo-2.16.0.alpha1 spec/integration/client_connectivity_spec.rb
mongo-2.15.0 spec/integration/client_connectivity_spec.rb