diff options
author | Colby Swandale <colby@taplaboratories.com> | 2017-12-09 22:07:39 +1100 |
---|---|---|
committer | Colby Swandale <colby@taplaboratories.com> | 2017-12-09 23:50:33 +1100 |
commit | 2122a050d285165e676a632e2c0152c2499a2524 (patch) | |
tree | 1e44169e134be26d8e3569d1b62effe980fe891e | |
parent | 953acf7eb7c27f8fb569713c5276e12561687d6d (diff) | |
download | bundler-2122a050d285165e676a632e2c0152c2499a2524.tar.gz |
Let users generate gemfiles in paths whos parent path contains a Gemfile
-rw-r--r-- | lib/bundler/cli/init.rb | 6 | ||||
-rw-r--r-- | spec/commands/init_spec.rb | 23 |
2 files changed, 21 insertions, 8 deletions
diff --git a/lib/bundler/cli/init.rb b/lib/bundler/cli/init.rb index 50e01f54fb..fa53e7c74b 100644 --- a/lib/bundler/cli/init.rb +++ b/lib/bundler/cli/init.rb @@ -36,11 +36,7 @@ module Bundler private def gemfile - @gemfile ||= begin - Bundler.default_gemfile - rescue GemfileNotFound - Bundler.feature_flag.init_gems_rb? ? "gems.rb" : "Gemfile" - end + @gemfile ||= Bundler.feature_flag.init_gems_rb? ? "gems.rb" : "Gemfile" end end end diff --git a/spec/commands/init_spec.rb b/spec/commands/init_spec.rb index 0441e62e13..f4ff436179 100644 --- a/spec/commands/init_spec.rb +++ b/spec/commands/init_spec.rb @@ -15,18 +15,35 @@ RSpec.describe "bundle init" do context "when a Gemfile already exists" do before do - gemfile <<-G + 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("Gemfile")) } + expect { bundle :init }.not_to change { File.read(bundled_app("gems.rb")) } end it "notifies the user that an existing Gemfile already exists" do bundle :init - expect(out).to include("Gemfile already exists") + expect(out).to include("gems.rb already exists") + end + end + + context "when a Gemfile exists in a parent directory" 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 |