summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-06-24 11:11:13 +0000
committerBundlerbot <bot@bundler.io>2019-06-24 11:11:13 +0000
commit547975644e93d1c421a468ab5e2396b5b953158b (patch)
tree2c44b7d35c41f7ee9375118a67a3e510d76f1f91
parentc5dcdfbc3617d1ecf551f047456d4ea03a18f930 (diff)
parentf47421f92d5d72c674347840e38c6ac100876f4d (diff)
downloadbundler-547975644e93d1c421a468ab5e2396b5b953158b.tar.gz
Merge #7209
7209: Add a minimum ruby version to the generated gemspec r=hsbt a=deivid-rodriguez This PR is a finished version of #4397. ### What was the end-user problem that led to this PR? The problem was that the generated gemspec for new gems does not impose a minimum ruby version. ### What is your fix for the problem, implemented in this PR? My fix is to set the minimum ruby version in the generated gemspec to the minimum ruby version supported by bundler itself. ### Why did you choose this fix out of the possible options? I chose this fix because it's simple. Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net> Co-authored-by: Miklos Fazekas <mfazekas@szemafor.com>
-rw-r--r--lib/bundler/templates/newgem/newgem.gemspec.tt1
-rw-r--r--spec/commands/newgem_spec.rb27
2 files changed, 16 insertions, 12 deletions
diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt
index 18060942c3..7feae6b18c 100644
--- a/lib/bundler/templates/newgem/newgem.gemspec.tt
+++ b/lib/bundler/templates/newgem/newgem.gemspec.tt
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
<%- if config[:mit] -%>
spec.license = "MIT"
<%- end -%>
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb
index 222e6ce2d4..e6d6794462 100644
--- a/spec/commands/newgem_spec.rb
+++ b/spec/commands/newgem_spec.rb
@@ -16,6 +16,8 @@ RSpec.describe "bundle gem" do
expect(bundled_app("#{gem_name}/lib/test/gem/version.rb")).to exist
end
+ let(:generated_gemspec) { Bundler::GemHelper.new(bundled_app(gem_name).to_s).gemspec }
+
before do
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
git_config_content = <<-EOF
@@ -39,22 +41,22 @@ RSpec.describe "bundle gem" do
shared_examples_for "git config is present" do
context "git config user.{name,email} present" do
it "sets gemspec author to git user.name if available" do
- expect(generated_gem.gemspec.authors.first).to eq("Bundler User")
+ expect(generated_gemspec.authors.first).to eq("Bundler User")
end
it "sets gemspec email to git user.email if available" do
- expect(generated_gem.gemspec.email.first).to eq("user@example.com")
+ expect(generated_gemspec.email.first).to eq("user@example.com")
end
end
end
shared_examples_for "git config is absent" do
it "sets gemspec author to default message if git user.name is not set or empty" do
- expect(generated_gem.gemspec.authors.first).to eq("TODO: Write your name")
+ expect(generated_gemspec.authors.first).to eq("TODO: Write your name")
end
it "sets gemspec email to default message if git user.email is not set or empty" do
- expect(generated_gem.gemspec.email.first).to eq("TODO: Write your email address")
+ expect(generated_gemspec.email.first).to eq("TODO: Write your email address")
end
end
@@ -116,7 +118,6 @@ RSpec.describe "bundle gem" do
context "README.md" do
let(:gem_name) { "test_gem" }
- let(:generated_gem) { Bundler::GemHelper.new(bundled_app(gem_name).to_s) }
context "git config github.user present" do
before do
@@ -232,8 +233,6 @@ RSpec.describe "bundle gem" do
execute_bundle_gem(gem_name)
end
- let(:generated_gem) { Bundler::GemHelper.new(bundled_app(gem_name).to_s) }
-
it "generates a gem skeleton" do
expect(bundled_app("test_gem/test_gem.gemspec")).to exist
expect(bundled_app("test_gem/Gemfile")).to exist
@@ -271,10 +270,16 @@ RSpec.describe "bundle gem" do
end
it "sets gemspec metadata['allowed_push_host']" do
- expect(generated_gem.gemspec.metadata["allowed_push_host"]).
+ expect(generated_gemspec.metadata["allowed_push_host"]).
to match(/mygemserver\.com/)
end
+ it "sets a minimum ruby version" do
+ bundler_gemspec = Bundler::GemHelper.new(File.expand_path("../..", __dir__)).gemspec
+
+ expect(bundler_gemspec.required_ruby_version).to eq(generated_gemspec.required_ruby_version)
+ end
+
it "requires the version file" do
expect(bundled_app("test_gem/lib/test_gem.rb").read).to match(%r{require "test_gem/version"})
end
@@ -359,7 +364,7 @@ RSpec.describe "bundle gem" do
end
it "depends on a specific version of rspec" do
- rspec_dep = generated_gem.gemspec.development_dependencies.find {|d| d.name == "rspec" }
+ rspec_dep = generated_gemspec.development_dependencies.find {|d| d.name == "rspec" }
expect(rspec_dep).to be_specific
end
@@ -406,7 +411,7 @@ RSpec.describe "bundle gem" do
end
it "depends on a specific version of minitest" do
- rspec_dep = generated_gem.gemspec.development_dependencies.find {|d| d.name == "minitest" }
+ rspec_dep = generated_gemspec.development_dependencies.find {|d| d.name == "minitest" }
expect(rspec_dep).to be_specific
end
@@ -516,8 +521,6 @@ RSpec.describe "bundle gem" do
execute_bundle_gem(gem_name)
end
- let(:generated_gem) { Bundler::GemHelper.new(bundled_app(gem_name).to_s) }
-
it "generates a gem skeleton" do
expect(bundled_app("test-gem/test-gem.gemspec")).to exist
expect(bundled_app("test-gem/Gemfile")).to exist