diff --git a/lib/sinatra/test.rb b/lib/sinatra/test.rb index 65c49c51..dcf6e1c5 100644 --- a/lib/sinatra/test.rb +++ b/lib/sinatra/test.rb @@ -4,6 +4,10 @@ module Sinatra module Test include Rack::Utils + def self.included(base) + Sinatra::Default.set(:environment, :test) + end + attr_reader :app, :request, :response def self.deprecate(framework) diff --git a/test/helper.rb b/test/helper.rb index 92a1416c..a28fedc8 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -19,10 +19,6 @@ end class Test::Unit::TestCase include Sinatra::Test - def setup - Sinatra::Default.set :environment, :test - end - # Sets up a Sinatra::Base subclass defined with the block # given. Used in setup or individual spec methods to establish # the application. diff --git a/test/test_test.rb b/test/test_test.rb index 8c13303d..0a4dd293 100644 --- a/test/test_test.rb +++ b/test/test_test.rb @@ -130,6 +130,12 @@ describe 'Sinatra::Test' do assert called end + it 'sets the environment to :test on include' do + Sinatra::Default.set(:environment, :production) + Class.new { include Sinatra::Test } + assert_equal :test, Sinatra::Default.environment + end + def test_TestHarness session = Sinatra::TestHarness.new(@app) response = session.get('/')