summaryrefslogtreecommitdiff
path: root/spec/bundler/commands/init_spec.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-12 06:15:44 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-12 06:15:44 +0000
commita1a20cfaa2cf73ae8daaf2123d7c5b513427162e (patch)
tree7f112577119ebda6c3dfd71cbc24f1bc559280ae /spec/bundler/commands/init_spec.rb
parentf1c33950998bf2d38d9416aa4f5dfe7f9f869f86 (diff)
Merge 1-16-stable branch of bundler.
It's rc version for bundler-1.16.1. I'm going to update it version after official release from bundler team. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/bundler/commands/init_spec.rb')
-rw-r--r--spec/bundler/commands/init_spec.rb66
1 files changed, 39 insertions, 27 deletions
diff --git a/spec/bundler/commands/init_spec.rb b/spec/bundler/commands/init_spec.rb
index 0441e62e13..c1cd7b90c8 100644
--- a/spec/bundler/commands/init_spec.rb
+++ b/spec/bundler/commands/init_spec.rb
@@ -13,9 +13,9 @@ RSpec.describe "bundle init" do
expect(bundled_app("gems.rb")).to be_file
end
- context "when a Gemfile already exists" do
+ context "when a Gemfile already exists", :bundler => "< 2" do
before do
- gemfile <<-G
+ create_file "Gemfile", <<-G
gem "rails"
G
end
@@ -30,14 +30,14 @@ RSpec.describe "bundle init" do
end
end
- context "when a gems.rb already exists" do
+ context "when gems.rb already exists", :bundler => ">= 2" do
before do
- create_file "gems.rb", <<-G
+ create_file("gems.rb", <<-G)
gem "rails"
G
end
- it "does not change existing gem.rb files" do
+ it "does not change existing Gemfiles" do
expect { bundle :init }.not_to change { File.read(bundled_app("gems.rb")) }
end
@@ -47,6 +47,40 @@ RSpec.describe "bundle init" do
end
end
+ context "when a Gemfile exists in a parent directory", :bundler => "< 2" do
+ let(:subdir) { "child_dir" }
+
+ it "lets users generate a Gemfile in a child directory" do
+ bundle! :init
+
+ FileUtils.mkdir bundled_app(subdir)
+
+ Dir.chdir bundled_app(subdir) do
+ bundle! :init
+ end
+
+ expect(out).to include("Writing new Gemfile")
+ expect(bundled_app("#{subdir}/Gemfile")).to be_file
+ end
+ end
+
+ context "when a gems.rb file exists in a parent directory", :bundler => ">= 2" do
+ let(:subdir) { "child_dir" }
+
+ it "lets users generate a Gemfile in a child directory" do
+ bundle! :init
+
+ FileUtils.mkdir bundled_app(subdir)
+
+ Dir.chdir bundled_app(subdir) do
+ bundle! :init
+ end
+
+ expect(out).to include("Writing new gems.rb")
+ expect(bundled_app("#{subdir}/gems.rb")).to be_file
+ end
+ end
+
context "given --gemspec option", :bundler => "< 2" do
let(:spec_file) { tmp.join("test.gemspec") }
@@ -94,28 +128,6 @@ RSpec.describe "bundle init" do
context "when init_gems_rb setting is enabled" do
before { bundle "config init_gems_rb true" }
- it "generates a gems.rb file" do
- bundle :init
- expect(bundled_app("gems.rb")).to exist
- end
-
- context "when gems.rb already exists" do
- before do
- create_file("gems.rb", <<-G)
- gem "rails"
- G
- end
-
- it "does not change existing Gemfiles" do
- expect { bundle :init }.not_to change { File.read(bundled_app("gems.rb")) }
- end
-
- it "notifies the user that an existing gems.rb already exists" do
- bundle :init
- expect(out).to include("gems.rb already exists")
- end
- end
-
context "given --gemspec option", :bundler => "< 2" do
let(:spec_file) { tmp.join("test.gemspec") }