diff options
author | Adam Wanninger <ajwann@ajwann.codes> | 2017-11-27 18:36:03 -0500 |
---|---|---|
committer | Adam Wanninger <ajwann@ajwann.codes> | 2018-01-25 10:01:13 -0500 |
commit | 0c9fb52e7ec69b970a554bb2101f746c0226d0fb (patch) | |
tree | fbf4116a2c9b64c671ad024d523d6c6d87c8b607 | |
parent | 40911ddadbd052e342ebb99ad4188efffc8290c1 (diff) | |
download | bundler-0c9fb52e7ec69b970a554bb2101f746c0226d0fb.tar.gz |
use Bundler.ui.info instead of exception
-rw-r--r-- | lib/bundler/cli/doctor.rb | 18 | ||||
-rw-r--r-- | spec/commands/doctor_spec.rb | 8 |
2 files changed, 13 insertions, 13 deletions
diff --git a/lib/bundler/cli/doctor.rb b/lib/bundler/cli/doctor.rb index 93366c33a9..95be4bca0b 100644 --- a/lib/bundler/cli/doctor.rb +++ b/lib/bundler/cli/doctor.rb @@ -101,25 +101,25 @@ module Bundler end def check_for_files_not_owned_by_current_user_but_still_rw - return unless any_files_not_owned_by_current_user_but_still_rw? + return unless files_not_owned_by_current_user_but_still_rw.any? Bundler.ui.warn "Files exist in Bundler home that are owned by another " \ - "user, but are stil readable/writable" + "user, but are stil readable/writable. These files are: #{files_not_owned_by_current_user_but_still_rw.join("\n")}" end def check_for_files_not_readable_or_writable - return unless any_files_not_readable_or_writable? - raise ProductionError, "Files exist in Bundler home that are not " \ - "readable/writable to the current user" + return unless files_not_readable_or_writable.any? + Bundler.ui.warn "Files exist in Bundler home that are not " \ + "readable/writable to the current user. These files are: #{files_not_readable_or_writable.join("\n")}" end - def any_files_not_readable_or_writable? - Find.find(Bundler.home.to_s).any? do |f| + def files_not_readable_or_writable + Find.find(Bundler.home.to_s).select do |f| !(File.writable?(f) && File.readable?(f)) end end - def any_files_not_owned_by_current_user_but_still_rw? - Find.find(Bundler.home.to_s).any? do |f| + def files_not_owned_by_current_user_but_still_rw + Find.find(Bundler.home.to_s).select do |f| (File.stat(f).uid != Process.uid) && (File.writable?(f) && File.readable?(f)) end diff --git a/spec/commands/doctor_spec.rb b/spec/commands/doctor_spec.rb index 3e58adff36..3effaf955c 100644 --- a/spec/commands/doctor_spec.rb +++ b/spec/commands/doctor_spec.rb @@ -66,9 +66,9 @@ RSpec.describe "bundle doctor" do allow(stat).to receive(:uid) { Process.uid } allow(File).to receive(:writable?).with(unwritable_file) { false } allow(File).to receive(:readable?).with(unwritable_file) { false } - expect { doctor.run }.to raise_error( - Bundler::ProductionError, - "Files exist in Bundler home that are not readable/writable to the current user" + expect { doctor.run }.not_to raise_error + expect(@stdout.string).to include( + "Files exist in Bundler home that are not readable/writable to the current user. These files are: #{unwritable_file}" ) end @@ -81,6 +81,6 @@ RSpec.describe "bundle doctor" do allow(File).to receive(:writable?).with(unwritable_file) { true } allow(File).to receive(:readable?).with(unwritable_file) { true } expect { Bundler::CLI::Doctor.new({}).run }.not_to raise_error - expect(@stdout.string).to include("Files exist in Bundler home that are owned by another user, but are stil readable/writable") + expect(@stdout.string).to include("Files exist in Bundler home that are owned by another user, but are stil readable/writable. These files are: #{unwritable_file}") end end |