Sha256: 9c8d9434983c89a1bcc001c79b38214cbd12e12af90d65208ad3b940e95b27d8

Contents?: true

Size: 1.88 KB

Versions: 9

Compression:

Stored size: 1.88 KB

Contents

# frozen_string_literal: true
# rubocop:todo all

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

9 entries across 9 versions & 2 rubygems

Version Path
mongo-2.21.0 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.20.1 spec/spec_tests/read_write_concern_document_spec.rb
mogno-2.20.0 spec/spec_tests/read_write_concern_document_spec.rb
mogno-1.0.0 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.20.0 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.19.3 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.19.2 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.19.1 spec/spec_tests/read_write_concern_document_spec.rb
mongo-2.19.0 spec/spec_tests/read_write_concern_document_spec.rb