summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gordon <agordon@sessionm.com>2018-10-25 13:43:46 -0400
committerAlex Gordon <agordon@sessionm.com>2018-10-25 13:43:46 -0400
commit30c44265e7d883c9fbfbf3a18a9ff5cbc03c7486 (patch)
tree2bf3ad35cb9ba60c9b237fd7d54d89312b1e9823
parent9d59fa41ef43aaccc6cf867a69a49648510c4df7 (diff)
downloadbundler-30c44265e7d883c9fbfbf3a18a9ff5cbc03c7486.tar.gz
fix error with path objects in array
-rw-r--r--lib/bundler.rb2
-rw-r--r--spec/bundler/bundler_spec.rb13
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 2411ac20c2..1cb3b4fb21 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -371,7 +371,7 @@ EOF
unwritable_files = files.reject {|f| File.writable?(f) }
sudo_needed = !unwritable_files.empty?
if sudo_needed
- Bundler.ui.warn "Following files may not be writable, so sudo is needed:\n #{unwritable_files.sort.map(&:to_s).join("\n ")}"
+ Bundler.ui.warn "Following files may not be writable, so sudo is needed:\n #{unwritable_files.map(&:to_s).sort.join("\n ")}"
end
end
diff --git a/spec/bundler/bundler_spec.rb b/spec/bundler/bundler_spec.rb
index 4759005c0c..194d6752b2 100644
--- a/spec/bundler/bundler_spec.rb
+++ b/spec/bundler/bundler_spec.rb
@@ -378,9 +378,11 @@ EOF
before do
allow(Bundler).to receive(:which).with("sudo").and_return("/usr/bin/sudo")
FileUtils.mkdir_p("tmp/vendor/bundle")
+ FileUtils.mkdir_p("tmp/vendor/bin_dir")
end
after do
FileUtils.rm_rf("tmp/vendor/bundle")
+ FileUtils.rm_rf("tmp/vendor/bin_dir")
if Bundler.respond_to?(:remove_instance_variable)
Bundler.remove_instance_variable(:@requires_sudo_ran)
Bundler.remove_instance_variable(:@requires_sudo)
@@ -401,13 +403,24 @@ EOF
before do
FileUtils.touch("tmp/vendor/bundle/unwritable1.txt")
FileUtils.touch("tmp/vendor/bundle/unwritable2.txt")
+ FileUtils.touch("tmp/vendor/bin_dir/unwritable3.txt")
FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable1.txt")
FileUtils.chmod(0o400, "tmp/vendor/bundle/unwritable2.txt")
+ FileUtils.chmod(0o400, "tmp/vendor/bin_dir/unwritable3.txt")
end
it "should return true and display warn message" do
allow(Bundler).to receive(:bundle_path).and_return(Pathname("tmp/vendor/bundle"))
+ bin_dir = Pathname("tmp/vendor/bin_dir/")
+
+ # allow File#writable? to be called with args other than the stubbed on below
+ allow(File).to receive(:writable?).and_call_original
+
+ # fake make the directory unwritable
+ allow(File).to receive(:writable?).with(bin_dir).and_return(false)
+ allow(Bundler).to receive(:system_bindir).and_return(Pathname("tmp/vendor/bin_dir/"))
message = <<-MESSAGE.chomp
Following files may not be writable, so sudo is needed:
+ tmp/vendor/bin_dir/
tmp/vendor/bundle/unwritable1.txt
tmp/vendor/bundle/unwritable2.txt
MESSAGE