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
|
module Test
|
||||||
include Rack::Utils
|
include Rack::Utils
|
||||||
|
|
||||||
|
def self.included(base)
|
||||||
|
Sinatra::Default.set(:environment, :test)
|
||||||
|
end
|
||||||
|
|
||||||
attr_reader :app, :request, :response
|
attr_reader :app, :request, :response
|
||||||
|
|
||||||
def self.deprecate(framework)
|
def self.deprecate(framework)
|
||||||
|
|
|
@ -19,10 +19,6 @@ end
|
||||||
class Test::Unit::TestCase
|
class Test::Unit::TestCase
|
||||||
include Sinatra::Test
|
include Sinatra::Test
|
||||||
|
|
||||||
def setup
|
|
||||||
Sinatra::Default.set :environment, :test
|
|
||||||
end
|
|
||||||
|
|
||||||
# Sets up a Sinatra::Base subclass defined with the block
|
# Sets up a Sinatra::Base subclass defined with the block
|
||||||
# given. Used in setup or individual spec methods to establish
|
# given. Used in setup or individual spec methods to establish
|
||||||
# the application.
|
# the application.
|
||||||
|
|
|
@ -130,6 +130,12 @@ describe 'Sinatra::Test' do
|
||||||
assert called
|
assert called
|
||||||
end
|
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
|
def test_TestHarness
|
||||||
session = Sinatra::TestHarness.new(@app)
|
session = Sinatra::TestHarness.new(@app)
|
||||||
response = session.get('/')
|
response = session.get('/')
|
||||||
|
|
Loading…
Reference in New Issue