1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
# 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
|