Skip to content

Commit

Permalink
Zeus: Wrap Gem::LoadError in more informative error
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmire committed Jan 28, 2016
1 parent f1da108 commit 88a47e5
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions custom_plan.rb
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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
Expand Down

0 comments on commit 88a47e5

Please sign in to comment.