Sha256: 951c4022f5bea9ddc0199d9602919b50d6165607e0fca328a1d2fd0302e941f9

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

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

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

spec_precondition 'memcached is running' do
  cache = Dalli::Client.new('localhost:11211')
  cache.set('active', true)
end

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::MemCache

describe Innate::Session 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

3 entries across 3 versions & 1 rubygems

Version Path
ramaze-2011.12.28 spec/ramaze/session/memcache.rb
ramaze-2011.10.23 spec/ramaze/session/memcache.rb
ramaze-2011.07.25 spec/ramaze/session/memcache.rb