1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

AP tests: detect missing dependencies and automatically run bundler

This commit is contained in:
Joshua Peek 2009-09-13 16:37:30 -05:00
parent 6d214c953b
commit 076d7f885e
3 changed files with 34 additions and 4 deletions

View file

@ -6,8 +6,8 @@ $:.unshift(File.dirname(__FILE__) + '/lib')
$:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
$:.unshift(File.dirname(__FILE__) + '/fixtures/alternate_helpers')
bundler = File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'environment')
require bundler if File.exist?("#{bundler}.rb")
require 'bundler_helper'
ensure_requirable %w( rack rack/test sqlite3 builder memcache tzinfo )
ENV['TMPDIR'] = File.join(File.dirname(__FILE__), 'tmp')

View file

@ -5,8 +5,8 @@ $:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib')
$:.unshift(File.dirname(__FILE__) + '/../lib')
$:.unshift(File.dirname(__FILE__) + '/lib')
bundler = File.join(File.dirname(__FILE__), '..', '..', 'vendor', 'gems', 'environment')
require bundler if File.exist?("#{bundler}.rb")
require 'bundler_helper'
ensure_requirable %w( rack rack/test )
require 'test/unit'
require 'active_support'

View file

@ -0,0 +1,30 @@
BUNDLER_ENV_FILE = File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'environment')
def load_bundled_gems
load_bundled_gems! if File.exist?("#{BUNDLER_ENV_FILE}.rb")
end
def load_bundled_gems!
puts "Checking if the bundled testing requirements are up to date..."
result = system "gem bundle"
unless result
puts "The gem bundler is not installed. Installing."
system "gem install bundler"
system "gem bundle"
end
require BUNDLER_ENV_FILE
end
def ensure_requirable(libs)
load_bundled_gems
begin
libs.each { |lib| require lib }
rescue LoadError => e
puts "Missing required libs to run test"
puts e.message
load_bundled_gems!
end
end