Sha256: 08696e59245016f13666c3a0cf59d4ee178f77569b36a6b0b4ec98ecabac8c87
Contents?: true
Size: 777 Bytes
Versions: 18
Compression:
Stored size: 777 Bytes
Contents
# frozen_string_literal: true # encoding: utf-8 require 'spec_helper' describe 'OperationFailure code' do let(:collection_name) { 'operation_failure_code_spec' } let(:collection) { authorized_client[collection_name] } before do collection.delete_many end context 'duplicate key error' do it 'is set' do begin collection.insert_one(_id: 1) collection.insert_one(_id: 1) fail('Should have raised') rescue Mongo::Error::OperationFailure => e expect(e.code).to eq(11000) # 4.0 and 4.2 sharded clusters set code name. # 4.0 and 4.2 replica sets and standalones do not, # and neither do older versions. expect([nil, 'DuplicateKey']).to include(e.code_name) end end end end
Version data entries
18 entries across 18 versions & 1 rubygems