From 88a47e50ce88625773eb1edc440cbcb0bb3c7310 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Sun, 24 Jan 2016 22:10:58 -0700 Subject: [PATCH] Zeus: Wrap Gem::LoadError in more informative error --- custom_plan.rb | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/custom_plan.rb b/custom_plan.rb index 9283d6bf3..edb06a25a 100644 --- a/custom_plan.rb +++ b/custom_plan.rb @@ -1,12 +1,27 @@ -require 'zeus/rails' +require 'zeus' +require 'zeus/plan' require_relative 'spec/support/tests/current_bundle' -class CustomPlan < Zeus::Plan - def initialize - super - @rails_plan = Zeus::Rails.new +class CouldNotBootZeusError < StandardError + def self.create(underlying_error:) + new(<<-MESSAGE) +Couldn't boot Zeus. + +Bundler tried to load a gem that has already been loaded (but the +versions are different). + +Note that Appraisal requires Rake, and so you'll want to make sure that +the Gemfile is pointing to the same version of Rake that you have +installed locally. + +The original message is as follows: + +#{underlying_error.message} + MESSAGE end +end +class CustomPlan < Zeus::Plan def boot ENV['BUNDLE_GEMFILE'] = File.expand_path( "../gemfiles/#{latest_appraisal}.gemfile", @@ -19,10 +34,11 @@ def boot $LOAD_PATH << File.expand_path('../spec', __FILE__) require_relative 'spec/support/unit/load_environment' + rescue Gem::LoadError => error + raise CouldNotBootZeusError.create(underlying_error: error) end def after_fork - # @rails_plan.reconnect_activerecord end def test_environment