Sha256: a01096044c7641fd49e539865e6eba4450bba108ec12318acc65e17bb2196a66

Contents?: true

Size: 926 Bytes

Versions: 6

Compression:

Stored size: 926 Bytes

Contents

require 'spec_helper'

describe Mongo::Operation::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

6 entries across 6 versions & 1 rubygems

Version Path
mongo-2.6.4 spec/mongo/operation/remove_user_spec.rb
mongo-2.6.2 spec/mongo/operation/remove_user_spec.rb
mongo-2.6.1 spec/mongo/operation/remove_user_spec.rb
mongo-2.6.0 spec/mongo/operation/remove_user_spec.rb
mongo-2.5.3 spec/mongo/operation/remove_user_spec.rb
mongo-2.5.2 spec/mongo/operation/remove_user_spec.rb