This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Add a minimum ruby version to the generated gemspec #7209
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,8 @@ def gem_skeleton_assertions(gem_name) | |
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 @@ def gem_skeleton_assertions(gem_name) | |
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("[email protected]") | ||
expect(generated_gemspec.email.first).to eq("[email protected]") | ||
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 @@ def gem_skeleton_assertions(gem_name) | |
|
||
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 @@ def create_temporary_dir(dir) | |
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 @@ def create_temporary_dir(dir) | |
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 @@ def create_temporary_dir(dir) | |
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 @@ def create_temporary_dir(dir) | |
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 @@ def create_temporary_dir(dir) | |
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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand it will, this should be the same as https://github.com/bundler/bundler/blob/c5dcdfbc3617d1ecf551f047456d4ea03a18f930/bundler.gemspec#L34. But to prevent loading bundler gemspec during generating new gem, this is hardcoded in here, but covered by spec ensuring those two values are the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, although I didn't really consider your alternative solution: load bundler's gemspec, and load the minimum version from there. It sounds like it might be a better approach since it's more DRY and we don't need a spec to keep the minimum versions in sync... 🤔.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I was thinking loading bundler's gemspec is overkill during generating new gem. Anyway I can inspect that option if needed. Feel free to ping me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I don't have a strong opinion, this is probably good enough.