Set :environment to :test when Sinatra::Test is included
This commit is contained in:
parent
5018264d62
commit
93b19a3492
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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('/')
|
||||
|
|
Loading…
Reference in New Issue