Sha256: 02f5e9d7edb88aa8ae4fa6fa36690ff1f59c6a966c9b50595cad0c32855ff618

Contents?: true

Size: 777 Bytes

Versions: 17

Compression:

Stored size: 777 Bytes

Contents

require 'spec/helper'

class MockSequelUser
  def profile
    "Arthur Dent, fearful human in outer space!"
  end

  def self.authenticate(hash)
    new if hash.values_at('name', 'password') == %w[arthur 42]
  end
end

class SpecUserHelper < Ramaze::Controller
  map '/'
  helper :user
  trait :user_model => MockSequelUser

  def status
    logged_in?
  end

  def login
    user_login
  end

  def profile
    user.profile
  end
end

describe Ramaze::Helper::User do
  behaves_like 'browser'
  ramaze :adapter => :webrick

  should 'login' do
    Browser.new do
      get('/status').should == 'false'
      get('/login', 'name' => 'arthur', 'password' => '42')
      get('/status').should == 'true'
      get('/profile').should == MockSequelUser.new.profile
    end
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
Pistos-ramaze-2008.09 spec/ramaze/helper/user.rb
Pistos-ramaze-2008.12 spec/ramaze/helper/user.rb
Pistos-ramaze-2009.01 spec/ramaze/helper/user.rb
Pistos-ramaze-2009.02 spec/ramaze/helper/user.rb
manveru-ramaze-2008.07 spec/ramaze/helper/user.rb
manveru-ramaze-2008.08 spec/ramaze/helper/user.rb
manveru-ramaze-2008.09 spec/ramaze/helper/user.rb
manveru-ramaze-2008.10 spec/ramaze/helper/user.rb
manveru-ramaze-2008.12 spec/ramaze/helper/user.rb
manveru-ramaze-2009.01 spec/ramaze/helper/user.rb
ptomato-ramaze-2009.02.1 spec/ramaze/helper/user.rb
ptomato-ramaze-2009.02 spec/ramaze/helper/user.rb
ramaze-2009.01 spec/ramaze/helper/user.rb
ramaze-2008.11 spec/ramaze/helper/user.rb
ramaze-2008.06 spec/ramaze/helper/user.rb
ramaze-2009.03 spec/ramaze/helper/user.rb
ramaze-2009.02 spec/ramaze/helper/user.rb