aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/bundler_helper.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-09-13 15:10:29 -0500
committerJoshua Peek <josh@joshpeek.com>2009-09-13 15:10:29 -0500
commitfff3f0ae0cec1061f8b3e5cb44e189e94a4ad44f (patch)
tree57619ca4425ec52d14e080fedf2bdbe16a28aaed /activesupport/test/bundler_helper.rb
parentef38e6756272ecc1c91247639f76532b79c84bfd (diff)
downloadrails-fff3f0ae0cec1061f8b3e5cb44e189e94a4ad44f.tar.gz
rails-fff3f0ae0cec1061f8b3e5cb44e189e94a4ad44f.tar.bz2
rails-fff3f0ae0cec1061f8b3e5cb44e189e94a4ad44f.zip
Detect missing dependencies and automatically run bundler
Diffstat (limited to 'activesupport/test/bundler_helper.rb')
-rw-r--r--activesupport/test/bundler_helper.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/activesupport/test/bundler_helper.rb b/activesupport/test/bundler_helper.rb
new file mode 100644
index 0000000000..5f3e982f19
--- /dev/null
+++ b/activesupport/test/bundler_helper.rb
@@ -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