diff options
author | Adam Wanninger <ajwann@users.noreply.github.com> | 2017-08-07 19:01:34 -0400 |
---|---|---|
committer | Adam Wanninger <ajwann@users.noreply.github.com> | 2017-08-07 19:01:40 -0400 |
commit | 7b7da1fa6f7b65fc5c680e262fa7ad7d55f05e4d (patch) | |
tree | 89c6e91ee0f83dd80a5f4477fa1c091a0d6d62f4 | |
parent | 5f0b690ef07b4ed33f092c79e2b0944c95b738bc (diff) | |
download | bundler-7b7da1fa6f7b65fc5c680e262fa7ad7d55f05e4d.tar.gz |
raise BundlerError and expand error messsage
-rw-r--r-- | lib/bundler/shared_helpers.rb | 11 | ||||
-rw-r--r-- | spec/bundler/shared_helpers_spec.rb | 28 |
2 files changed, 16 insertions, 23 deletions
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index a189b8dc21..06087449ab 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -205,10 +205,13 @@ module Bundler def validate_bundle_path return unless Bundler.bundle_path.to_s.match(File::PATH_SEPARATOR) - puts "WARNING: Your bundle path contains a '#{File::PATH_SEPARATOR}', " \ - "which is the path separator for your system." - puts "Please change your bundle path path to not include '#{File::PATH_SEPARATOR}'." - exit(1) + message = "WARNING: Your bundle path contains a '#{File::PATH_SEPARATOR}', " \ + "which is the path separator for your system. Bundler cannot " \ + "function correctly when the Bundle path contains the " \ + "system's PATH separator. Please change your " \ + "bundle path to not include '#{File::PATH_SEPARATOR}'." \ + "\nYour current bundle path is '#{Bundler.bundle_path}'." + raise Bundler::BundlerError, message end def find_gemfile(order_matters = false) diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb index 59e304c5e7..88ff06a380 100644 --- a/spec/bundler/shared_helpers_spec.rb +++ b/spec/bundler/shared_helpers_spec.rb @@ -264,25 +264,15 @@ RSpec.describe Bundler::SharedHelpers do it "exits if bundle path contains the path seperator" do stub_const("File::PATH_SEPARATOR", ":".freeze) allow(Bundler).to receive(:bundle_path) { "so:me/dir/bin" } - begin - expect(subject.send(:validate_bundle_path)).to raise_exception(SystemExit). - and output("WARNING: Your bundle path contains a ':', which is the" \ - " path separator for your system. Please change your" \ - " bundle path path to not include ':'.") - rescue SystemExit => e - expect(e.status).to eq(1) - end - - stub_const("File::PATH_SEPARATOR", "^".freeze) - allow(Bundler).to receive(:bundle_path) { "so^me/dir/bin" } - begin - expect(subject.send(:validate_bundle_path)).to raise_exception(SystemExit). - and output("WARNING: Your bundle path contains a '^', which is the" \ - " path separator for your system. Please change your" \ - " bundle path path to not include '^'.") - rescue SystemExit => e - expect(e.status).to eq(1) - end + expect { subject.send(:validate_bundle_path) }.to raise_error( + Bundler::BundlerError, + "WARNING: Your bundle path contains a ':', which is the " \ + "path separator for your system. Bundler cannot " \ + "function correctly when the Bundle path contains the " \ + "system's PATH separator. Please change your " \ + "bundle path to not include ':'.\nYour current bundle " \ + "path is '#{Bundler.bundle_path}'." + ) end context "ENV['PATH'] does not exist" do |