Sha256: bc25c6d9d534844c9d26c81c0dff19462e6966fa89aa4c2e04158af8df1acfd6

Contents?: true

Size: 942 Bytes

Versions: 3

Compression:

Stored size: 942 Bytes

Contents

require 'spec_helper'

describe Mongo::Operation::Write::Command::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)
      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)
      end

      it 'raises an exception' do
        expect {
          operation.execute(root_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/remove_user_spec.rb
mongo-2.5.1 spec/mongo/operation/write/command/remove_user_spec.rb
mongo-2.5.0 spec/mongo/operation/write/command/remove_user_spec.rb