Sha256: c7bca7122bdfb512bb1084a0827b942ca52da5b7dbb80557f0df61913ebb3675

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe Mongo::Operation::DropIndex do
  before do
    authorized_collection.indexes.drop_all
  end

  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: SpecConfig.instance.test_db,
          coll_name: TEST_COLL,
          index_name: 'another_-1'
        )
      end

      let(:response) do
        operation.execute(authorized_primary, client: nil)
      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: SpecConfig.instance.test_db,
          coll_name: TEST_COLL,
          index_name: 'another_blah'
        )
      end

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

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mongo-2.13.3 spec/mongo/operation/drop_index_spec.rb
mongo-2.14.1 spec/mongo/operation/drop_index_spec.rb
mongo-2.13.2 spec/mongo/operation/drop_index_spec.rb
mongo-2.14.0 spec/mongo/operation/drop_index_spec.rb
mongo-2.14.0.rc1 spec/mongo/operation/drop_index_spec.rb
mongo-2.13.1 spec/mongo/operation/drop_index_spec.rb
mongo-2.12.4 spec/mongo/operation/drop_index_spec.rb
mongo-2.13.0 spec/mongo/operation/drop_index_spec.rb
mongo-2.12.3 spec/mongo/operation/drop_index_spec.rb
mongo-2.13.0.rc1 spec/mongo/operation/drop_index_spec.rb
mongo-2.12.2 spec/mongo/operation/drop_index_spec.rb
mongo-2.13.0.beta1 spec/mongo/operation/drop_index_spec.rb
mongo-2.12.1 spec/mongo/operation/drop_index_spec.rb
mongo-2.12.0.rc0 spec/mongo/operation/drop_index_spec.rb