Sha256: 380acb898b2108e7b04e57a7aa29bd8ed79b5465031b890a5c9799dcee00c03a

Contents?: true

Size: 726 Bytes

Versions: 29

Compression:

Stored size: 726 Bytes

Contents

require 'spec_helper'

describe 'OperationFailure code' do
  let(:collection_name) { 'operation_error_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

29 entries across 29 versions & 1 rubygems

Version Path
mongo-2.13.3 spec/integration/operation_failure_code_spec.rb
mongo-2.14.1 spec/integration/operation_failure_code_spec.rb
mongo-2.13.2 spec/integration/operation_failure_code_spec.rb
mongo-2.14.0 spec/integration/operation_failure_code_spec.rb
mongo-2.14.0.rc1 spec/integration/operation_failure_code_spec.rb
mongo-2.13.1 spec/integration/operation_failure_code_spec.rb
mongo-2.12.4 spec/integration/operation_failure_code_spec.rb
mongo-2.11.6 spec/integration/operation_failure_code_spec.rb
mongo-2.13.0 spec/integration/operation_failure_code_spec.rb
mongo-2.12.3 spec/integration/operation_failure_code_spec.rb
mongo-2.13.0.rc1 spec/integration/operation_failure_code_spec.rb
mongo-2.12.2 spec/integration/operation_failure_code_spec.rb
mongo-2.10.5 spec/integration/operation_failure_code_spec.rb
mongo-2.11.5 spec/integration/operation_failure_code_spec.rb
mongo-2.13.0.beta1 spec/integration/operation_failure_code_spec.rb
mongo-2.12.1 spec/integration/operation_failure_code_spec.rb
mongo-2.12.0.rc0 spec/integration/operation_failure_code_spec.rb
mongo-2.11.4 spec/integration/operation_failure_code_spec.rb
mongo-2.10.4 spec/integration/operation_failure_code_spec.rb
mongo-2.11.3 spec/integration/operation_failure_code_spec.rb