Sha256: fd79e1574fb0185bd099c4d2ac46759664bd423c387ba4acb14279365a2a7566

Contents?: true

Size: 819 Bytes

Versions: 1

Compression:

Stored size: 819 Bytes

Contents

module UserTestHelper
  VALID_USER_PARAMS = {
    :name => 'Mahmut Bulut',
    :login => 'regularlambda',
    :password => 'kissme',
    :password_confirmation => 'kissme',
    :email => 'scienceblock@gmail.com'
  }
  
  def user_params(options = {})
    params = VALID_USER_PARAMS.dup
    params.merge!(:login => @user_login) if @user_login
    params.merge!(options)
  end
  
  def destroy_test_user(login = @user_login)
    while user = get_test_user(login) do
      user.destroy
    end
  end
  
  def get_test_user(login = @user_login)
    User.find_by_login(login)
  end
  
  def create_test_user(options = {})
    options[:login] ||= @user_login if @user_login
    user = User.new user_params(options)
    if user.save
      user
    else
      raise "user <#{user.inspect}> could not be saved"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kajam-1.0.3.rc2 test/helpers/user_test_helper.rb