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
bmizerany-sinatra-0.9.1 compat/sessions_test.rb
darkhelmet-sinatra-0.9.1.1 compat/sessions_test.rb
darkhelmet-sinatra-0.9.1 compat/sessions_test.rb
sinatra-sinatra-0.9.1.1 compat/sessions_test.rb
sinatra-sinatra-0.9.1.2 compat/sessions_test.rb
sinatra-sinatra-0.9.1.3 compat/sessions_test.rb
sinatra-sinatra-0.9.1 compat/sessions_test.rb
sinatra-sinatra-0.9.2 compat/sessions_test.rb
sinatra-0.9.6 compat/sessions_test.rb
sinatra-0.9.5 compat/sessions_test.rb
akamai_bookmarklet-0.1.2 vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/sessions_test.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/sinatra-0.9.4/compat/sessions_test.rb
akamai_bookmarklet-0.1.1 vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/sessions_test.rb
akamai_bookmarklet-0.1.0 vendor/gems/ruby/1.8/gems/sinatra-0.9.4/compat/sessions_test.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/sinatra-0.9.4/compat/sessions_test.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/sinatra-0.9.4/compat/sessions_test.rb
middleman-0.12.0.pre3 lib/middleman/vendor/gems/gems/sinatra-0.9.4/compat/sessions_test.rb
middleman-0.12.0.pre2 lib/middleman/vendor/gems/gems/sinatra-0.9.4/compat/sessions_test.rb
middleman-0.12.0.pre lib/middleman/vendor/gems/gems/sinatra-0.9.4/compat/sessions_test.rb
middleman-0.10.17 vendor/gems/gems/sinatra-0.9.4/compat/sessions_test.rb