Sha256: dee86bf7e4849b2cd51565c691d3f969665005b9bf146cc9e193482676f12b3b

Contents?: true

Size: 968 Bytes

Versions: 6

Compression:

Stored size: 968 Bytes

Contents

require 'spec_helper'

describe Mongo::Operation::CreateUser do

  describe '#execute' do

    let(:user) do
      Mongo::Auth::User.new(
        user: 'durran',
        password: 'password',
        roles: [ Mongo::Auth::Roles::READ_WRITE ]
      )
    end

    let(:operation) do
      described_class.new(user: user, db_name: TEST_DB)
    end

    after do
      root_authorized_client.database.users.remove('durran')
    end

    context 'when user creation was successful' do

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

      it 'saves the user in the database' do
        expect(response).to be_successful
      end
    end

    context 'when creation was not successful' do

      it 'raises an exception' do
        expect {
          operation.execute(root_authorized_primary)
          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/create_user_spec.rb
mongo-2.6.2 spec/mongo/operation/create_user_spec.rb
mongo-2.6.1 spec/mongo/operation/create_user_spec.rb
mongo-2.6.0 spec/mongo/operation/create_user_spec.rb
mongo-2.5.3 spec/mongo/operation/create_user_spec.rb
mongo-2.5.2 spec/mongo/operation/create_user_spec.rb