Sha256: 74eca586a7d8a778b5d1aa8815b46e6fac8696ca9cb7bb93955bb1147b6f52f1

Contents?: true

Size: 1.03 KB

Versions: 25

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe Mongo::Operation::Write::DropIndex do

  describe '#execute' do

    context 'when the index exists' do

      let(:spec) do
        { another: -1 }
      end

      before do
        authorized_collection.indexes.create_one(spec, unique: true)
      end

      let(:operation) do
        described_class.new(
          db_name: TEST_DB,
          coll_name: TEST_COLL,
          index_name: 'another_-1'
        )
      end

      let(:response) do
        operation.execute(authorized_primary.context)
      end

      it 'removes the index' do
        expect(response).to be_successful
      end
    end

    context 'when the index does not exist' do

      let(:operation) do
        described_class.new(
          db_name: TEST_DB,
          coll_name: TEST_COLL,
          index_name: 'another_blah'
        )
      end

      it 'raises an exception' do
        expect {
          operation.execute(authorized_primary.context)
        }.to raise_error(Mongo::Error::OperationFailure)
      end
    end
  end
end

Version data entries

25 entries across 24 versions & 3 rubygems

Version Path
mongo-2.2.7 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.2.6 spec/mongo/operation/write/drop_index_spec.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongo-2.2.5/spec/mongo/operation/write/drop_index_spec.rb
mongo-2.2.5 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.2.4 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.2.3 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.2.2 spec/mongo/operation/write/drop_index_spec.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/mongo-2.2.1/spec/mongo/operation/write/drop_index_spec.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/mongo-2.2.1/spec/mongo/operation/write/drop_index_spec.rb
mongo-2.2.1 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.2.0 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.2.0.rc0 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.1.2 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.1.1 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.1.0 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.1.0.rc0 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.1.0.beta spec/mongo/operation/write/drop_index_spec.rb
mongo-2.0.6 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.0.5 spec/mongo/operation/write/drop_index_spec.rb
mongo-2.0.4 spec/mongo/operation/write/drop_index_spec.rb