diff --git a/compat/sessions_test.rb b/compat/sessions_test.rb index b50cb8fbea..9d9622db87 100644 --- a/compat/sessions_test.rb +++ b/compat/sessions_test.rb @@ -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 diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 5770eae00c..254172f7ee 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -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) }