Sha256: 2fc339544aa7496a6b8cca6a957e1663cbf68490f32c552a3895f07d7f5b7589

Contents?: true

Size: 999 Bytes

Versions: 26

Compression:

Stored size: 999 Bytes

Contents

require 'spec_helper'

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

Version data entries

26 entries across 25 versions & 3 rubygems

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