Sha256: 7042dd2227c25b84d90aa016afa4c055e663a94030bb5d81b815197c001f078a

Contents?: true

Size: 1.49 KB

Versions: 19

Compression:

Stored size: 1.49 KB

Contents

#          Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
# All files in this distribution are subject to the terms of the Ruby license.

require 'spec/helper'

class TCAuthHelperController < Ramaze::Controller
  map '/'
  helper :auth

  def index
    self.class.name
  end

  def session_inspect
    session.inspect
  end

  def secured
    "Secret content"
  end
  before(:secured){ login_required }
end

class TCAuthHashHelperController < TCAuthHelperController
  map '/hash'
  trait :auth_table => {
      'manveru' => '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8'
    }
end

class TCAuthMethodHelperController < TCAuthHelperController
  map '/method'
  trait :auth_table => :auth_table

  def auth_table
    { 'manveru' => '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8' }
  end
end

class TCAuthLambdaHelperController < TCAuthHelperController
  map '/lambda'
  trait :auth_table => lambda{
      { 'manveru' => '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8' }
    }
end

describe "StackHelper" do
  behaves_like 'browser'

  ramaze :adapter => :webrick
  [ TCAuthHashHelperController,
    TCAuthMethodHelperController,
    TCAuthLambdaHelperController
  ].each do |controller|

    it controller.to_s do
      Browser.new(Ramaze::Global.mapping.invert[controller]) do
        get('/secured').should == ''
        post('/login', 'username' => 'manveru', 'password' => 'password')
        get('/secured').should == 'Secret content'
        get('/logout')
        get('/secured').should == ''
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 5 rubygems

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