2008-04-07 17:45:36 -04:00
|
|
|
require File.dirname(__FILE__) + '/helper'
|
|
|
|
|
|
|
|
context "Sessions" do
|
|
|
|
|
2008-04-15 04:25:09 -04:00
|
|
|
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-15 04:25:09 -04:00
|
|
|
|
2008-04-07 17:45:36 -04:00
|
|
|
specify "should be able to store data accross requests" do
|
2008-04-15 04:25:09 -04:00
|
|
|
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
|