Sha256: 3797fc16fc17c0bca44fe526cc5d2114350e63f726b0e6fe2959af9eb868f875

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

ENV['RACK_ENV'] = 'test'

require './spec'
require 'rspec'
require 'rack/test'

describe '${ClassName}' do
  def app
    Sinatra::Application
  end

  it 'creates an user' do
    username = 'Gennaro'
    email    = 'gennaro@bullo.pk'
    password = 'sonopropriounbullo!'
    level    = User.empty? ? User.founder : User.user

    User.exists?(username).should be_false
    user = User.signup username, email, password, level
    user.errors.should            be_empty
    user.guest?.should            be_false
    user.founder?.should          be_true
    User.exists?(username).should be_true

    user = User.signup username, email, password, level
    user.errors.should_not be_empty
  end

  it 'logs in a user' do
    username = 'Gennaro'
    password = 'sonopropriounbullo!'

    User.exists?(username).should         be_true
    User.login(username, password).should be_true
    user = User.get username
    user.session.should have(29).chars
  end

  it 'logs out a user' do
    username = 'Gennaro'

    user = User.get username
    user.session.should have(29).chars
    user.logout
    user.session.should be_empty
  end

  it 'recovers lost password' do
    username     = 'Gennaro'
    new_password = 'sonounnuovobullo!'

    User.login(username, new_password).should be_false

    passcode = User.lost_password username
    passcode.should_not be_false
    passcode.should have(29).chars

    recovery = User.password_recovery username, passcode, new_password
    recovery.should be_true

    User.login(username, new_password).should be_true
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gennaro-0.3.2.1 templates/authentication/spec/user_spec.rb
gennaro-0.3.2 templates/authentication/spec/user_spec.rb
gennaro-0.3.1.3 templates/authentication/spec/user_spec.rb