Permalink
Browse files

Set sensible defaults on Default for test env

  • Loading branch information...
1 parent 8edd8c8 commit 5a33a9586f6d3aa959ee7b3f4f7f0831476dcaa5 @sr sr committed Feb 22, 2009
Showing with 16 additions and 13 deletions.
  1. +2 −2 lib/sinatra/base.rb
  2. +4 −8 test/helper.rb
  3. +10 −3 test/options_test.rb
View
@@ -940,10 +940,10 @@ class Default < Base
set :raise_errors, Proc.new { test? }
set :dump_errors, true
set :sessions, false
- set :logging, true
+ set :logging, Proc.new { ! test? }
set :methodoverride, true
set :static, true
- set :run, false
+ set :run, Proc.new { ! test? }
def self.register(*extensions, &block) #:nodoc:
added_methods = extensions.map {|m| m.public_instance_methods }.flatten
View
@@ -20,12 +20,7 @@ class Test::Unit::TestCase
include Sinatra::Test
def setup
- Sinatra::Default.set(
- :environment => :test,
- :run => false,
- :raise_errors => true,
- :logging => false
- )
+ Sinatra::Default.set :environment, :test
end
# Sets up a Sinatra::Base subclass defined with the block
@@ -37,13 +32,14 @@ def mock_app(base=Sinatra::Base, &block)
def restore_default_options
Sinatra::Default.set(
+ :environment => :development,
:raise_errors => Proc.new { test? },
:dump_errors => true,
:sessions => false,
- :logging => true,
+ :logging => Proc.new { ! test? },
:methodoverride => true,
:static => true,
- :run => false
+ :run => Proc.new { ! test? }
)
end
end
View
@@ -147,8 +147,12 @@ def clean_backtrace(trace)
assert ! @base.run?
end
- it 'is disabled on Default' do
- assert ! @default.run?
+ it 'is enabled on Default when not in test environment' do
+ assert @default.development?
+ assert @default.run?
+
+ @default.set :environment, :development
+ assert @default.run?
end
# TODO: it 'is enabled when $0 == app_file'
@@ -219,8 +223,11 @@ def clean_backtrace(trace)
assert ! @base.logging?
end
- it 'is enabled on Default' do
+ it 'is enabled on Default when not in test environment' do
assert @default.logging?
+
+ @default.set :environment, :test
+ assert ! @default.logging
end
# TODO: it 'uses Rack::CommonLogger when enabled' do

0 comments on commit 5a33a95

Please sign in to comment.