Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (39 sloc) 1.099 kb
9d32965 Ryan Tomayko 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
8 libdir = File.dirname(File.dirname(__FILE__)) + '/lib'
9 $LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
10
c00a25e Ryan Tomayko Test framework refactoring
rtomayko authored
11 require 'sinatra/base'
045f93b Simon Rozet Convert tests to custom test/spec/mini [#87]
sr authored
12 require 'sinatra/test/unit'
c00a25e Ryan Tomayko Test framework refactoring
rtomayko authored
13
14 module Sinatra::Test
15 # Sets up a Sinatra::Base subclass defined with the block
16 # given. Used in setup or individual spec methods to establish
17 # the application.
18 def mock_app(base=Sinatra::Base, &block)
19 @app = Sinatra.new(base, &block)
20 end
21 end
661090e Ryan Tomayko Allow assertions in mock_app request context
rtomayko authored
22
23 class Sinatra::Base
24 # Allow assertions in request context
25 include Test::Unit::Assertions
26 end
045f93b Simon Rozet Convert tests to custom test/spec/mini [#87]
sr authored
27
28 ##
29 # test/spec/mini
30 # http://pastie.caboo.se/158871
31 # chris@ozmm.org
32 #
33 def describe(*args, &block)
34 return super unless (name = args.first) && block
35 klass = Class.new(Test::Unit::TestCase) do
36 def self.it(name, &block)
37 define_method("test_#{name.gsub(/\W/,'_')}", &block)
38 end
39 def self.xspecify(*args) end
40 def self.before(&block) define_method(:setup, &block) end
41 def self.after(&block) define_method(:teardown, &block) end
42 end
43 klass.class_eval &block
44 end
Something went wrong with that request. Please try again.