Sha256: fa480527f4a8f640a487560654863b98581d25ae6a2b1f1a075ea90840dfaadf

Contents?: true

Size: 1.13 KB

Versions: 26

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe Mongo::Operation::Write::RemoveUser do

  describe '#execute' do

    before do
      root_authorized_client.database.users.create(
        'durran',
        password: 'password', roles: [ Mongo::Auth::Roles::READ_WRITE ]
      )
    end

    let(:operation) do
      described_class.new(user_name: 'durran', db_name: TEST_DB)
    end

    context 'when user removal was successful' do

      let!(:response) do
        operation.execute(root_authorized_primary.context)
      end

      it 'removes the user from the database' do
        expect(response).to be_successful
      end
    end

    context 'when removal was not successful' do

      before do
        operation.execute(root_authorized_primary.context)
      end

      it 'raises an exception', if: write_command_enabled? do
        expect {
          operation.execute(root_authorized_primary.context)
        }.to raise_error(Mongo::Error::OperationFailure)
      end

      it 'does not raise an exception', unless: write_command_enabled? do
        expect(operation.execute(root_authorized_primary.context).written_count).to eq(0)
      end
    end
  end
end

Version data entries

26 entries across 25 versions & 3 rubygems

Version Path
mongo-2.2.7 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.2.6 spec/mongo/operation/write/remove_user_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/remove_user_spec.rb
mongo-2.2.5 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.2.4 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.2.3 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.2.2 spec/mongo/operation/write/remove_user_spec.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/mongo-2.2.1/spec/mongo/operation/write/remove_user_spec.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/mongo-2.2.1/spec/mongo/operation/write/remove_user_spec.rb
mongo-2.2.1 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.2.0 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.2.0.rc0 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.1.2 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.1.1 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.1.0 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.1.0.rc0 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.1.0.beta spec/mongo/operation/write/remove_user_spec.rb
mongo-2.0.6 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.0.5 spec/mongo/operation/write/remove_user_spec.rb
mongo-2.0.4 spec/mongo/operation/write/remove_user_spec.rb