summaryrefslogtreecommitdiff
path: root/spec/commands/init_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/commands/init_spec.rb')
-rw-r--r--spec/commands/init_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/commands/init_spec.rb b/spec/commands/init_spec.rb
index c1cd7b90c8..9b5bd95814 100644
--- a/spec/commands/init_spec.rb
+++ b/spec/commands/init_spec.rb
@@ -64,6 +64,24 @@ RSpec.describe "bundle init" do
end
end
+ context "when the dir is not writable by the current user" do
+ let(:subdir) { "child_dir" }
+
+ it "notifies the user that it can not write to it" do
+ FileUtils.mkdir bundled_app(subdir)
+ # chmod a-w it
+ mode = File.stat(bundled_app(subdir)).mode ^ 0o222
+ FileUtils.chmod mode, bundled_app(subdir)
+
+ Dir.chdir bundled_app(subdir) do
+ bundle :init
+ end
+
+ expect(out).to include("directory is not writable")
+ expect(Dir[bundled_app("#{subdir}/*")]).to be_empty
+ end
+ end
+
context "when a gems.rb file exists in a parent directory", :bundler => ">= 2" do
let(:subdir) { "child_dir" }