Sha256: 5928512cbab9daf0adab2ad561f115746368b495daaba98fc17c53bac5e0da9b

Contents?: true

Size: 1.83 KB

Versions: 22

Compression:

Stored size: 1.83 KB

Contents

require 'spec_helper'
require 'runners/read_write_concern_document'

READ_WRITE_CONCERN_DOCUMENT_TESTS =
  Dir.glob("#{CURRENT_PATH}/spec_tests/data/read_write_concern/document/*.yml").sort

describe 'Connection String' do
  READ_WRITE_CONCERN_DOCUMENT_TESTS.each do |test_path|
    spec = ReadWriteConcernDocument::Spec.new(test_path)

    context(spec.description) do

      spec.tests.each_with_index do |test, index|

        context test.description do

          let(:actual) do
            Mongo::WriteConcern.get(test.input_document)
          end

          let(:actual_server_document) do
            Utils.camelize_hash(actual.options)
          end

          if test.valid?

            it 'parses successfully' do
              expect do
                actual
              end.not_to raise_error
            end

            it 'has expected server document' do
              expect(actual_server_document).to eq(test.server_document)
            end

            if test.server_default?
              it 'is server default' do
                expect(actual.options).to eq({})
              end
            end

            if test.server_default? == false
              it 'is not server default' do
                expect(actual.options).not_to eq({})
              end
            end

            if test.acknowledged?
              it 'is acknowledged' do
                expect(actual.acknowledged?).to be true
              end
            end

            if test.acknowledged? == false
              it 'is not acknowledged' do
                expect(actual.acknowledged?).to be false
              end
            end

          else

            it 'is invalid' do
              expect do
                actual
              end.to raise_error(Mongo::Error::InvalidWriteConcern)
            end

          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
mongo-2.13.3 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.14.1 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.15.0.alpha spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.13.2 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.14.0 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.14.0.rc1 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.13.1 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.12.4 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.11.6 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.13.0 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.12.3 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.13.0.rc1 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.12.2 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.11.5 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.13.0.beta1 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.12.1 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.12.0.rc0 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.11.4 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.11.3 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.11.2 spec/spec_tests/read_write_concern_document_spec.rb