Permalink
Browse files

Don't require rubygems in tests; do fall back if necessary

  • Loading branch information...
1 parent 045f93b commit 9d329651b4f8644f2ffd5eab7393191a6d7f25bb @rtomayko rtomayko committed Jan 20, 2009
Showing with 11 additions and 2 deletions.
  1. +1 −0 Rakefile
  2. +10 −2 test/helper.rb
View
1 Rakefile
@@ -9,6 +9,7 @@ task :spec => :test
Rake::TestTask.new(:test) do |t|
t.test_files = FileList['test/*_test.rb']
+ t.ruby_opts = ['-rubygems'] if defined? Gem
end
desc 'Run compatibility specs (requires test/spec)'
View
12 test/helper.rb
@@ -1,5 +1,13 @@
-require 'rubygems' # required so that sinatra/base can require rack
-$:.unshift File.dirname(File.dirname(__FILE__)) + '/lib'
+begin
+ require 'rack'
+rescue LoadError
+ require 'rubygems'
+ require 'rack'
+end
+
+libdir = File.dirname(File.dirname(__FILE__)) + '/lib'
+$LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
+
require 'sinatra/base'
require 'sinatra/test/unit'

0 comments on commit 9d32965

Please sign in to comment.