mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
Add simple tests for session support
This commit is contained in:
parent
ecb95f941e
commit
b9bc95a94a
1 changed files with 40 additions and 0 deletions
40
test/sessions_test.rb
Normal file
40
test/sessions_test.rb
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
require File.dirname(__FILE__) + '/helper'
|
||||||
|
|
||||||
|
context "Sessions" do
|
||||||
|
|
||||||
|
specify "should be off by default" do
|
||||||
|
Sinatra.application = nil
|
||||||
|
|
||||||
|
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_options(:sessions => true)
|
||||||
|
Sinatra.application = nil
|
||||||
|
|
||||||
|
get '/foo' do
|
||||||
|
session[:test] = true
|
||||||
|
"asdf"
|
||||||
|
end
|
||||||
|
|
||||||
|
get '/bar' do
|
||||||
|
session[:test] == true ? "true" : "false"
|
||||||
|
end
|
||||||
|
|
||||||
|
get_it '/foo', {}, 'HTTP_HOST' => 'foo.sinatrarb.com'
|
||||||
|
assert ok?
|
||||||
|
assert include?('Set-Cookie')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in a new issue