Skip to content

Commit 5c080f0

Browse files
committed
Remove version constraints on dev dependencies
Bundler doesn't need to have an opinion on the current version of these tools. We can just include them without specific constraint, and if the user doesn't want the most recent version for some reason they can add the necessary constraint themselves.
1 parent b26074a commit 5c080f0

3 files changed

Lines changed: 13 additions & 25 deletions

File tree

bundler/lib/bundler/cli/gem.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ class CLI
77
end
88

99
class CLI::Gem
10-
TEST_FRAMEWORK_VERSIONS = {
11-
"rspec" => "3.0",
12-
"minitest" => "5.16",
13-
"test-unit" => "3.0",
14-
}.freeze
15-
1610
DEFAULT_GITHUB_USERNAME = "[USERNAME]"
1711

1812
attr_reader :options, :gem_name, :thor, :name, :target, :extension
@@ -117,7 +111,6 @@ def run
117111

118112
if test_framework = ask_and_set_test_framework
119113
config[:test] = test_framework
120-
config[:test_framework_version] = TEST_FRAMEWORK_VERSIONS[test_framework]
121114

122115
case test_framework
123116
when "rspec"
@@ -203,12 +196,10 @@ def run
203196
config[:linter] = ask_and_set_linter
204197
case config[:linter]
205198
when "rubocop"
206-
config[:linter_version] = rubocop_version
207199
Bundler.ui.info "RuboCop enabled in config"
208200
templates.merge!("rubocop.yml.tt" => ".rubocop.yml")
209201
config[:ignore_paths] << ".rubocop.yml"
210202
when "standard"
211-
config[:linter_version] = standard_version
212203
Bundler.ui.info "Standard enabled in config"
213204
templates.merge!("standard.yml.tt" => ".standard.yml")
214205
config[:ignore_paths] << ".standard.yml"
@@ -472,14 +463,6 @@ def required_ruby_version
472463
"3.2.0"
473464
end
474465

475-
def rubocop_version
476-
"1.21"
477-
end
478-
479-
def standard_version
480-
"1.3"
481-
end
482-
483466
def github_username(git_username)
484467
if options[:github_username].nil?
485468
git_username

bundler/lib/bundler/templates/newgem/Gemfile.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ gem "rake-compiler"
1313
<%- end -%>
1414
<%- if config[:test] -%>
1515

16-
gem "<%= config[:test] %>", ">= <%= config[:test_framework_version] %>"
16+
gem "<%= config[:test] %>"
1717
<%- end -%>
1818
<%- if config[:linter] == "rubocop" -%>
1919

20-
gem "rubocop", ">= <%= config[:linter_version] %>"
20+
gem "rubocop"
2121
<%- elsif config[:linter] == "standard" -%>
2222

23-
gem "standard", ">= <%= config[:linter_version] %>"
23+
gem "standard"
2424
<%- end -%>

spec/commands/newgem_spec.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ def installed_go?
208208
builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
209209
builder.dependencies
210210
rubocop_dep = builder.dependencies.find {|d| d.name == "rubocop" }
211-
expect(rubocop_dep).not_to be_nil
211+
expect(rubocop_dep).not_to be_specific
212+
expect(rubocop_dep.requirement).to eq(Gem::Requirement.new([">= 0"]))
212213
end
213214

214215
it "generates a default .rubocop.yml" do
@@ -239,7 +240,8 @@ def installed_go?
239240
builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
240241
builder.dependencies
241242
standard_dep = builder.dependencies.find {|d| d.name == "standard" }
242-
expect(standard_dep).not_to be_nil
243+
expect(standard_dep).not_to be_specific
244+
expect(standard_dep.requirement).to eq(Gem::Requirement.new([">= 0"]))
243245
end
244246

245247
it "generates a default .standard.yml" do
@@ -746,13 +748,14 @@ def create_temporary_dir(dir)
746748
expect(ignore_paths).to include("spec/")
747749
end
748750

749-
it "depends on a specific version of rspec in generated Gemfile" do
751+
it "depends on a non-specific version of rspec in generated Gemfile" do
750752
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
751753
builder = Bundler::Dsl.new
752754
builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
753755
builder.dependencies
754756
rspec_dep = builder.dependencies.find {|d| d.name == "rspec" }
755757
expect(rspec_dep).not_to be_specific
758+
expect(rspec_dep.requirement).to eq(Gem::Requirement.new([">= 0"]))
756759
end
757760
end
758761

@@ -831,13 +834,14 @@ def create_temporary_dir(dir)
831834
bundle "gem #{gem_name} --test=minitest"
832835
end
833836

834-
it "depends on a specific version of minitest" do
837+
it "depends on a non-specific version of minitest" do
835838
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
836839
builder = Bundler::Dsl.new
837840
builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
838841
builder.dependencies
839842
minitest_dep = builder.dependencies.find {|d| d.name == "minitest" }
840843
expect(minitest_dep).not_to be_specific
844+
expect(minitest_dep.requirement).to eq(Gem::Requirement.new([">= 0"]))
841845
end
842846

843847
it "builds spec skeleton" do
@@ -892,13 +896,14 @@ def create_temporary_dir(dir)
892896
bundle "gem #{gem_name} --test=test-unit"
893897
end
894898

895-
it "depends on a specific version of test-unit" do
899+
it "depends on a non-specific version of test-unit" do
896900
allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile)
897901
builder = Bundler::Dsl.new
898902
builder.eval_gemfile(bundled_app("#{gem_name}/Gemfile"))
899903
builder.dependencies
900904
test_unit_dep = builder.dependencies.find {|d| d.name == "test-unit" }
901905
expect(test_unit_dep).not_to be_specific
906+
expect(test_unit_dep.requirement).to eq(Gem::Requirement.new([">= 0"]))
902907
end
903908

904909
it "builds spec skeleton" do

0 commit comments

Comments
 (0)