Permalink
Browse files

Never use Session middleware in test environment [#119]

  • Loading branch information...
1 parent 8edb409 commit 08b142b4cc5501277b74ece88b1edfae3e239348 @rtomayko rtomayko committed Feb 27, 2009
Showing with 4 additions and 1 deletion.
  1. +3 −0 compat/sessions_test.rb
  2. +1 −1 lib/sinatra/base.rb
View
@@ -21,6 +21,7 @@
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
@@ -34,6 +35,8 @@
get_it '/foo', :env => { :host => 'foo.sinatrarb.com' }
assert ok?
assert include?('Set-Cookie')
+
+ set_option :environment, :test
end
end
View
@@ -776,7 +776,7 @@ def prototype
# an instance of the class new was called on.
def new(*args, &bk)
builder = Rack::Builder.new
- builder.use Rack::Session::Cookie if sessions?
+ builder.use Rack::Session::Cookie if sessions? && !test?
builder.use Rack::CommonLogger if logging?
builder.use Rack::MethodOverride if methodoverride?
@middleware.each { |c, args, bk| builder.use(c, *args, &bk) }

0 comments on commit 08b142b

Please sign in to comment.