Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 60 lines (49 sloc) 1.341 kb
9d32965 @rtomayko Don't require rubygems in tests; do fall back if necessary
rtomayko authored
1 begin
2 require 'rack'
3 rescue LoadError
4 require 'rubygems'
5 require 'rack'
6 end
7
ff0d068 @sr Use contest instead of test/spec/mini
sr authored
8 testdir = File.dirname(__FILE__)
9 $LOAD_PATH.unshift testdir unless $LOAD_PATH.include?(testdir)
10
9d32965 @rtomayko Don't require rubygems in tests; do fall back if necessary
rtomayko authored
11 libdir = File.dirname(File.dirname(__FILE__)) + '/lib'
12 $LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
13
ff0d068 @sr Use contest instead of test/spec/mini
sr authored
14 require 'contest'
f9b13ee @sr Don't depend on sinatra/test/unit in internal test
sr authored
15 require 'sinatra/test'
16
17 class Sinatra::Base
18 # Allow assertions in request context
19 include Test::Unit::Assertions
20 end
21
ff0d068 @sr Use contest instead of test/spec/mini
sr authored
22 Sinatra::Base.set :environment, :test
23
f9b13ee @sr Don't depend on sinatra/test/unit in internal test
sr authored
24 class Test::Unit::TestCase
25 include Sinatra::Test
c00a25e @rtomayko Test framework refactoring
rtomayko authored
26
ff0d068 @sr Use contest instead of test/spec/mini
sr authored
27 class << self
28 alias_method :it, :test
60bdca9 @sr Initial Sinatra-specific ShowException middleware
sr authored
29 end
30
c00a25e @rtomayko Test framework refactoring
rtomayko authored
31 # Sets up a Sinatra::Base subclass defined with the block
32 # given. Used in setup or individual spec methods to establish
33 # the application.
34 def mock_app(base=Sinatra::Base, &block)
35 @app = Sinatra.new(base, &block)
36 end
2fdecae @sr Add full test coverage for all options
sr authored
37
38 def restore_default_options
39 Sinatra::Default.set(
5a33a95 @sr Set sensible defaults on Default for test env
sr authored
40 :environment => :development,
2fdecae @sr Add full test coverage for all options
sr authored
41 :raise_errors => Proc.new { test? },
60bdca9 @sr Initial Sinatra-specific ShowException middleware
sr authored
42 :show_exceptions => Proc.new { development? },
2fdecae @sr Add full test coverage for all options
sr authored
43 :dump_errors => true,
44 :sessions => false,
5a33a95 @sr Set sensible defaults on Default for test env
sr authored
45 :logging => Proc.new { ! test? },
2fdecae @sr Add full test coverage for all options
sr authored
46 :methodoverride => true,
47 :static => true,
5a33a95 @sr Set sensible defaults on Default for test env
sr authored
48 :run => Proc.new { ! test? }
2fdecae @sr Add full test coverage for all options
sr authored
49 )
50 end
c00a25e @rtomayko Test framework refactoring
rtomayko authored
51 end
661090e @rtomayko Allow assertions in mock_app request context
rtomayko authored
52
6569d1b @bdimcheff Added route block params in routing statements [#140]
bdimcheff authored
53 # Do not output warnings for the duration of the block.
54 def silence_warnings
55 $VERBOSE, v = nil, $VERBOSE
56 yield
57 ensure
58 $VERBOSE = v
59 end
Something went wrong with that request. Please try again.