Sha256: 4ebf995a9aed7b9246ca0501461409cfe369f0f0bdc049d3fa8e08ced3823598

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe Mongo::Operation::Write::Command::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)
      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)
        }.to raise_error(Mongo::Error::OperationFailure)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/mongo-2.5.1/spec/mongo/operation/write/command/drop_index_spec.rb
mongo-2.5.1 spec/mongo/operation/write/command/drop_index_spec.rb
mongo-2.5.0 spec/mongo/operation/write/command/drop_index_spec.rb