Sha256: 4f10b096ebd8ac087f3f7a0c18ed37ce53048fcbfff74f3f77861c8549136ffa

Contents?: true

Size: 1.46 KB

Versions: 9

Compression:

Stored size: 1.46 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe Warden::Serializers::Session do
  before(:each) do
    @env = env_with_params
    @env['rack.session'] ||= {}
    @session = Warden::Serializers::Session.new(@env)
  end

  it "should store data for the default scope" do
    @session.store("user", :default)
    @env['rack.session'].should == { "warden.user.default.key"=>"user" }
  end
  
  it "should check if a data is stored or not" do
    @session.should_not be_stored(:default)
    @session.store("user", :default)
    @session.should be_stored(:default)
  end

  it "should load an user from store" do
    @session.fetch(:default).should be_nil
    @session.store("user", :default)
    @session.fetch(:default).should == "user"
  end

  it "should store data based on the scope" do
    @session.store("user", :default)
    @session.fetch(:default).should == "user"
    @session.fetch(:another).should be_nil
  end

  it "should delete data from store" do
    @session.store("user", :default)
    @session.fetch(:default).should == "user"
    @session.delete(:default)
    @session.fetch(:default).should be_nil
  end

  it "should delete information from store if user cannot be retrieved" do
    @session.store("user", :default)
    @env['rack.session'].should have_key("warden.user.default.key")
    @session.instance_eval "def deserialize(key); nil; end" 
    @session.fetch(:default)
    @env['rack.session'].should_not have_key("warden.user.default.key")
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
warden-0.8.1 spec/warden/serializers/session_spec.rb
warden-0.8.0 spec/warden/serializers/session_spec.rb
warden-0.7.0 spec/warden/serializers/session_spec.rb
warden-0.6.5 spec/warden/serializers/session_spec.rb
warden-0.6.4 spec/warden/serializers/session_spec.rb
warden-0.6.3 spec/warden/serializers/session_spec.rb
warden-0.6.2 spec/warden/serializers/session_spec.rb
warden-0.6.1 spec/warden/serializers/session_spec.rb
warden-0.6.0 spec/warden/serializers/session_spec.rb