1
0
Fork 0
mirror of https://github.com/sinatra/sinatra synced 2023-03-27 23:18:01 -04:00
sinatra/test/sessions_test.rb

40 lines
773 B
Ruby
Raw Normal View History

2008-04-07 17:45:36 -04:00
require File.dirname(__FILE__) + '/helper'
context "Sessions" do
setup { Sinatra.application = nil }
specify "should be off by default" do
2008-04-07 17:45:36 -04:00
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
2008-04-07 17:45:36 -04:00
specify "should be able to store data accross requests" do
set_option :sessions, true
2008-04-07 17:45:36 -04:00
get '/foo' do
session[:test] = true
"asdf"
end
get '/bar' do
session[:test] == true ? "true" : "false"
end
2008-04-11 17:09:23 -04:00
get_it '/foo', :env => { :host => 'foo.sinatrarb.com' }
2008-04-07 17:45:36 -04:00
assert ok?
assert include?('Set-Cookie')
end
end