Sha256: f5a771affd74c50477aebf877a11d01156f947cfecc542f196a625b425437d45

Contents?: true

Size: 1005 Bytes

Versions: 4

Compression:

Stored size: 1005 Bytes

Contents

require File.expand_path('../../../../spec/helper', __FILE__)
spec_require 'sequel'

class SpecSession < Ramaze::Controller
  map '/'
  engine :None

  def index
    'No session here'
  end

  def init
    session[:counter] = 0
  end

  def view
    session[:counter]
  end

  def increment
    session[:counter] += 1
  end

  def decrement
    session[:counter] -= 1
  end

  def reset
    session.clear
  end
end

Ramaze::Cache.options.session = Ramaze::Cache::LRU

describe 'Sessions with Ramaze::Cache::LRU' do
  behaves_like :rack_test

  should 'initiate session as needed' do
    get '/'
    last_response.body.should == 'No session here'
    last_response['Set-Cookie'].should == nil

    get('/init')
    last_response.body.should == '0'

    1.upto(10) do |n|
      get('/increment').body.should == n.to_s
    end

    get('/reset')
    get('/view').body.should == ''
    get('/init').body.should == '0'

    -1.downto(-10) do |n|
      get('/decrement').body.should == n.to_s
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ramaze-2023.01.06 spec/ramaze/session/lru.rb
ramaze-2012.12.08 spec/ramaze/session/lru.rb
ramaze-2012.12.08b spec/ramaze/session/lru.rb
ramaze-2012.04.14 spec/ramaze/session/lru.rb