summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-04-10 17:21:10 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-04-11 15:27:56 +0200
commiteaadb8d8c853fbc7cc04de503eaf447f7ecc6361 (patch)
tree783791efde09e9d4167266e337d3361add514729
parentb711410759259c863709a585117804ee8b69e2b7 (diff)
downloadbundler-make_init_gems_rb_a_setting.tar.gz
Make `init_gems_rb` a regular settingmake_init_gems_rb_a_setting
I think it's nice that users can configure this and start using `gems.rb`. But there's no need to make this a feature flag and change its default value. Let's keep generating Gemfile's by default until we are ready, if we ever are.
-rw-r--r--lib/bundler/cli/init.rb2
-rw-r--r--lib/bundler/feature_flag.rb1
-rw-r--r--spec/commands/init_spec.rb96
3 files changed, 47 insertions, 52 deletions
diff --git a/lib/bundler/cli/init.rb b/lib/bundler/cli/init.rb
index 40df797269..65dd08dfe9 100644
--- a/lib/bundler/cli/init.rb
+++ b/lib/bundler/cli/init.rb
@@ -41,7 +41,7 @@ module Bundler
private
def gemfile
- @gemfile ||= Bundler.feature_flag.init_gems_rb? ? "gems.rb" : "Gemfile"
+ @gemfile ||= Bundler.settings[:init_gems_rb] ? "gems.rb" : "Gemfile"
end
end
end
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
index 2b46fc0b1d..3662372a8f 100644
--- a/lib/bundler/feature_flag.rb
+++ b/lib/bundler/feature_flag.rb
@@ -40,7 +40,6 @@ module Bundler
settings_flag(:forget_cli_options) { bundler_3_mode? }
settings_flag(:global_path_appends_ruby_scope) { bundler_3_mode? }
settings_flag(:global_gem_cache) { bundler_3_mode? }
- settings_flag(:init_gems_rb) { bundler_3_mode? }
settings_flag(:only_update_to_newer_versions) { bundler_3_mode? }
settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
diff --git a/spec/commands/init_spec.rb b/spec/commands/init_spec.rb
index 18f77f29fd..64849beeb9 100644
--- a/spec/commands/init_spec.rb
+++ b/spec/commands/init_spec.rb
@@ -1,19 +1,13 @@
# frozen_string_literal: true
RSpec.describe "bundle init" do
- it "generates a Gemfile", :bundler => "< 3" do
+ it "generates a Gemfile" do
bundle! :init
expect(out).to include("Writing new Gemfile")
expect(bundled_app("Gemfile")).to be_file
end
- it "generates a gems.rb", :bundler => "3" do
- bundle! :init
- expect(out).to include("Writing new gems.rb")
- expect(bundled_app("gems.rb")).to be_file
- end
-
- context "when a Gemfile already exists", :bundler => "< 3" do
+ context "when a Gemfile already exists" do
before do
create_file "Gemfile", <<-G
gem "rails"
@@ -30,24 +24,7 @@ RSpec.describe "bundle init" do
end
end
- context "when gems.rb already exists", :bundler => ">= 3" 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(err).to include("gems.rb already exists")
- end
- end
-
- context "when a Gemfile exists in a parent directory", :bundler => "< 3" do
+ 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
@@ -82,24 +59,7 @@ RSpec.describe "bundle init" do
end
end
- context "when a gems.rb file exists in a parent directory", :bundler => ">= 3" 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 => "< 3" do
+ context "given --gemspec option" do
let(:spec_file) { tmp.join("test.gemspec") }
it "should generate from an existing gemspec" do
@@ -115,11 +75,7 @@ RSpec.describe "bundle init" do
bundle :init, :gemspec => spec_file
- gemfile = if Bundler::VERSION[0, 2] == "2."
- bundled_app("Gemfile").read
- else
- bundled_app("gems.rb").read
- end
+ gemfile = bundled_app("Gemfile").read
expect(gemfile).to match(%r{source 'https://rubygems.org'})
expect(gemfile.scan(/gem "rack", "= 1.0.1"/).size).to eq(1)
expect(gemfile.scan(/gem "rspec", "= 1.2"/).size).to eq(1)
@@ -146,7 +102,47 @@ RSpec.describe "bundle init" do
context "when init_gems_rb setting is enabled" do
before { bundle "config set init_gems_rb true" }
- context "given --gemspec option", :bundler => "< 3" do
+ it "generates a gems.rb" do
+ bundle! :init
+ expect(out).to include("Writing new gems.rb")
+ expect(bundled_app("gems.rb")).to be_file
+ 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(err).to include("gems.rb already exists")
+ end
+ end
+
+ context "when a gems.rb file 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
+
+ context "given --gemspec option" do
let(:spec_file) { tmp.join("test.gemspec") }
before do