Permalink
Browse files

Convert tests to custom test/spec/mini [#87]

The "spec" task has been removed and Rake's built in
test helper is used to run specs now so we should be able to
test with multiple installed versions of Ruby.
  • Loading branch information...
1 parent c43058a commit 045f93be9171ce1542183cffcecf2a6fc253a2f2 @sr sr committed with rtomayko Jan 20, 2009
Showing with 382 additions and 375 deletions.
  1. +5 −11 Rakefile
  2. +20 −9 test/helper.rb
  3. +355 −353 test/helpers_test.rb
  4. +2 −2 test/middleware_test.rb
View
@@ -1,23 +1,17 @@
-require 'rubygems'
require 'rake/clean'
+require 'rake/testtask'
require 'fileutils'
task :default => :test
+task :spec => :test
# SPECS ===============================================================
-desc 'Run specs with story style output'
-task :spec do
- pattern = ENV['TEST'] || '.*'
- sh "specrb --testcase '#{pattern}' --specdox -Ilib:test test/*_test.rb"
-end
-
-desc 'Run specs with unit test style output'
-task :test do |t|
- sh "specrb -Ilib:test test/*_test.rb"
+Rake::TestTask.new(:test) do |t|
+ t.test_files = FileList['test/*_test.rb']
end
-desc 'Run compatibility specs'
+desc 'Run compatibility specs (requires test/spec)'
task :compat do |t|
pattern = ENV['TEST'] || '.*'
sh "specrb --testcase '#{pattern}' -Ilib:test compat/*_test.rb"
View
@@ -1,14 +1,7 @@
-begin
- require 'test/spec'
-rescue LoadError
- require 'rubygems'
- require 'test/spec'
-end
-
+require 'rubygems' # required so that sinatra/base can require rack
$:.unshift File.dirname(File.dirname(__FILE__)) + '/lib'
require 'sinatra/base'
-require 'sinatra/test'
-require 'sinatra/test/spec'
+require 'sinatra/test/unit'
module Sinatra::Test
# Sets up a Sinatra::Base subclass defined with the block
@@ -23,3 +16,21 @@ class Sinatra::Base
# Allow assertions in request context
include Test::Unit::Assertions
end
+
+##
+# test/spec/mini
+# http://pastie.caboo.se/158871
+# chris@ozmm.org
+#
+def describe(*args, &block)
+ return super unless (name = args.first) && block
+ klass = Class.new(Test::Unit::TestCase) do
+ def self.it(name, &block)
+ define_method("test_#{name.gsub(/\W/,'_')}", &block)
+ end
+ def self.xspecify(*args) end
+ def self.before(&block) define_method(:setup, &block) end
+ def self.after(&block) define_method(:teardown, &block) end
+ end
+ klass.class_eval &block
+end
Oops, something went wrong.

0 comments on commit 045f93b

Please sign in to comment.