[bundler/bundler] Factor out gemspec call inside let

https://github.com/bundler/bundler/commit/ae0ac190aa
This commit is contained in:
David Rodríguez 2019-06-17 10:23:47 +02:00 committed by Hiroshi SHIBATA
parent 10c0271f97
commit b014a2157f
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2

View File

@ -16,7 +16,7 @@ RSpec.describe "bundle gem" do
expect(bundled_app("#{gem_name}/lib/test/gem/version.rb")).to exist expect(bundled_app("#{gem_name}/lib/test/gem/version.rb")).to exist
end end
let(:generated_gem) { Bundler::GemHelper.new(bundled_app(gem_name).to_s) } let(:generated_gemspec) { Bundler::GemHelper.new(bundled_app(gem_name).to_s).gemspec }
before do before do
global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false" global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
@ -41,22 +41,22 @@ RSpec.describe "bundle gem" do
shared_examples_for "git config is present" do shared_examples_for "git config is present" do
context "git config user.{name,email} present" do context "git config user.{name,email} present" do
it "sets gemspec author to git user.name if available" 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 end
it "sets gemspec email to git user.email if available" do 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 end
end end
shared_examples_for "git config is absent" do 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 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 end
it "sets gemspec email to default message if git user.email is not set or empty" do 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
end end
@ -270,7 +270,7 @@ RSpec.describe "bundle gem" do
end end
it "sets gemspec metadata['allowed_push_host']" do 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/) to match(/mygemserver\.com/)
end end
@ -358,7 +358,7 @@ RSpec.describe "bundle gem" do
end end
it "depends on a specific version of rspec" do 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 expect(rspec_dep).to be_specific
end end
@ -405,7 +405,7 @@ RSpec.describe "bundle gem" do
end end
it "depends on a specific version of minitest" do 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 expect(rspec_dep).to be_specific
end end