Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Set :environment to :test when Sinatra::Test is included

  • Loading branch information...
commit 93b19a34927a21880523d3301b51d1dc2aad6538 1 parent 5018264
@bmizerany bmizerany authored rtomayko committed
Showing with 10 additions and 4 deletions.
  1. +4 −0 lib/sinatra/test.rb
  2. +0 −4 test/helper.rb
  3. +6 −0 test/test_test.rb
View
4 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)
View
4 test/helper.rb
@@ -19,10 +19,6 @@ class Sinatra::Base
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.
View
6 test/test_test.rb
@@ -130,6 +130,12 @@ def request_params
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('/')
Please sign in to comment.
Something went wrong with that request. Please try again.