Sha256: 7e509973859713fcdc8eeb779e14b6b70f133ae0abb6556e2e061533840bb2fa

Contents?: true

Size: 880 Bytes

Versions: 27

Compression:

Stored size: 880 Bytes

Contents

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

context "Sessions" do

  setup { Sinatra.application = nil }

  specify "should be off by default" do
    get '/asdf' do
      session[:test] = true
      "asdf"
    end

    get '/test' do
      session[:test] == true ? "true" : "false"
    end

    get_it '/asdf', {}, 'HTTP_HOST' => 'foo.sinatrarb.com'
    assert ok?
    assert !include?('Set-Cookie')
  end

  specify "should be able to store data accross requests" do
    set_option :sessions, true
    set_option :environment, :not_test # necessary because sessions are disabled

    get '/foo' do
      session[:test] = true
      "asdf"
    end

    get '/bar' do
      session[:test] == true ? "true" : "false"
    end

    get_it '/foo', :env => { :host => 'foo.sinatrarb.com' }
    assert ok?
    assert include?('Set-Cookie')

    set_option :environment, :test
  end

end

Version data entries

27 entries across 27 versions & 6 rubygems

Version Path
middleman-0.10.16 vendor/gems/gems/sinatra-0.9.4/compat/sessions_test.rb
middleman-0.10.15 vendor/gems/gems/sinatra-0.9.4/compat/sessions_test.rb
middleman-0.10.14 vendor/gems/gems/sinatra-0.9.4/compat/sessions_test.rb
sinatra-0.9.4 compat/sessions_test.rb
sinatra-0.9.1.1 compat/sessions_test.rb
sinatra-0.9.1 compat/sessions_test.rb
sinatra-0.9.2 compat/sessions_test.rb