Sha256: 658ccb103d7105dcd9f2d63fa4c9f60c575cdc4ba2c254eb8a860a4ba7ac2349

Contents?: true

Size: 1.92 KB

Versions: 15

Compression:

Stored size: 1.92 KB

Contents

require 'lite_spec_helper'

describe 'Uri Options' do
  include Mongo::ConnectionString

  URI_OPTIONS_TESTS.each do |file|

    spec = Mongo::ConnectionString::Spec.new(file)

    context(spec.description) do

      before(:all) do
        # Since the tests issue global assertions on Mongo::Logger,
        # we need to close all clients/stop monitoring to avoid monitoring
        # threads warning and interfering with these assertions
        ClientRegistry.instance.close_all_clients
      end

      spec.tests.each do |test|

        context "#{test.description}" do

          context 'when the uri should warn', if: test.warn? do

            before do
              expect(Mongo::Logger.logger).to receive(:warn)
            end

            it 'warns' do
              expect(test.client).to be_a(Mongo::Client)
            end
          end

          context 'when the uri is invalid', unless: test.valid? do

            it 'raises an error' do
              expect{
                test.uri
              }.to raise_exception(Mongo::Error::InvalidURI)
            end
          end

          context 'when the uri should not warn', if: !test.warn? && test.valid? do

            before do
              expect(Mongo::Logger.logger).not_to receive(:warn)
            end

            it 'does not raise an exception or warning' do
              expect(test.client).to be_a(Mongo::Client)
            end
          end

          context 'when the uri is valid', if: test.valid? do

            it 'creates a client with the correct hosts' do
              expect(test.client).to have_hosts(test)
            end

            it 'creates a client with the correct authentication properties' do
              expect(test.client).to match_auth(test)
            end

            it 'creates a client with the correct options' do
              expect(test.client).to match_options(test)
            end
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongo-2.8.0/spec/spec_tests/uri_options_spec.rb
mongo-2.10.5 spec/spec_tests/uri_options_spec.rb
mongo-2.10.4 spec/spec_tests/uri_options_spec.rb
mongo-2.10.3 spec/spec_tests/uri_options_spec.rb
mongo-2.9.2 spec/spec_tests/uri_options_spec.rb
mongo-2.10.2 spec/spec_tests/uri_options_spec.rb
mongo-2.10.1 spec/spec_tests/uri_options_spec.rb
mongo-2.10.0 spec/spec_tests/uri_options_spec.rb
mongo-2.9.1 spec/spec_tests/uri_options_spec.rb
mongo-2.10.0.rc0 spec/spec_tests/uri_options_spec.rb
mongo-2.9.1.rc0 spec/spec_tests/uri_options_spec.rb
mongo-2.9.0 spec/spec_tests/uri_options_spec.rb
mongo-2.9.0.rc1 spec/spec_tests/uri_options_spec.rb
mongo-2.9.0.rc0 spec/spec_tests/uri_options_spec.rb
mongo-2.8.0 spec/spec_tests/uri_options_spec.rb