summaryrefslogtreecommitdiff
path: root/spec/bundler/commands/newgem_spec.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2020-06-11 21:54:04 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-06-18 19:14:15 +0900
commitcc059b16b253d0f9622fa0c51606e722b190b526 (patch)
tree737fa7f6510f56888534cec792cbebecf303e9af /spec/bundler/commands/newgem_spec.rb
parent9be1baedbc14be036342cca3e363ae6f44153990 (diff)
Manually cherry-picked at https://github.com/rubygems/rubygems/commit/80260b3496e357bf96ffe6f381e29bf25b6749cb
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3212
Diffstat (limited to 'spec/bundler/commands/newgem_spec.rb')
-rw-r--r--spec/bundler/commands/newgem_spec.rb102
1 files changed, 100 insertions, 2 deletions
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index a31b28bf85..769b2678b3 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -585,6 +585,94 @@ RSpec.describe "bundle gem" do
it_behaves_like "test framework is present"
end
+ context "--ci with no arugment" do
+ it "does not generate any CI config" do
+ bundle "gem #{gem_name}"
+
+ expect(bundled_app("#{gem_name}/.github/workflows/main.yml")).to_not exist
+ expect(bundled_app("#{gem_name}/.travis.yml")).to_not exist
+ expect(bundled_app("#{gem_name}/.gitlab-ci.yml")).to_not exist
+ expect(bundled_app("#{gem_name}/.circleci/config.yml")).to_not exist
+ end
+ end
+
+ context "--ci set to github" do
+ it "generates a Github Actions config file" do
+ bundle "gem #{gem_name} --ci=github"
+
+ expect(bundled_app("#{gem_name}/.github/workflows/main.yml")).to exist
+ end
+ end
+
+ context "--ci set to gitlab" do
+ it "generates a Gitlab Ci config file" do
+ bundle "gem #{gem_name} --ci=gitlab"
+
+ expect(bundled_app("#{gem_name}/.gitlab-ci.yml")).to exist
+ end
+ end
+
+ context "--ci set to circle" do
+ it "generates a Circle Ci config file" do
+ bundle "gem #{gem_name} --ci=circle"
+
+ expect(bundled_app("#{gem_name}/.circleci/config.yml")).to exist
+ end
+ end
+
+ context "--ci set to travis" do
+ it "generates a Travis Ci config file" do
+ bundle "gem #{gem_name} --ci=travis"
+
+ expect(bundled_app("#{gem_name}/.travis.yml")).to exist
+ end
+ end
+
+ context "gem.ci setting set to none" do
+ it "doesnt generate any CI config" do
+ expect(bundled_app("#{gem_name}/.github/workflows/main.yml")).to_not exist
+ expect(bundled_app("#{gem_name}/.travis.yml")).to_not exist
+ expect(bundled_app("#{gem_name}/.gitlab-ci.yml")).to_not exist
+ expect(bundled_app("#{gem_name}/.circleci/config.yml")).to_not exist
+ end
+ end
+
+ context "gem.ci setting set to github" do
+ it "generates a Github Actions config file" do
+ bundle "config set gem.ci github"
+ bundle "gem #{gem_name}"
+
+ expect(bundled_app("#{gem_name}/.github/workflows/main.yml")).to exist
+ end
+ end
+
+ context "gem.ci setting set to travis" do
+ it "generates a Travis config file" do
+ bundle "config set gem.ci travis"
+ bundle "gem #{gem_name}"
+
+ expect(bundled_app("#{gem_name}/.travis.yml")).to exist
+ end
+ end
+
+ context "gem.ci setting set to gitlab" do
+ it "generates a Gitlab config file" do
+ bundle "config set gem.ci gitlab"
+ bundle "gem #{gem_name}"
+
+ expect(bundled_app("#{gem_name}/.gitlab-ci.yml")).to exist
+ end
+ end
+
+ context "gem.ci setting set to circleci" do
+ it "generates a CircleCI config file" do
+ bundle "config set gem.ci circle"
+ bundle "gem #{gem_name}"
+
+ expect(bundled_app("#{gem_name}/.circleci/config.yml")).to exist
+ end
+ end
+
context "gem.test setting set to test-unit" do
before do
bundle "config set gem.test test-unit"
@@ -875,8 +963,18 @@ Usage: "bundle gem NAME [OPTIONS]"
expect(bundled_app("foobar/Gemfile").read).to include('gem "rspec"')
end
+ it "asks about CI service" do
+ global_config "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__RUBOCOP" => "false"
+
+ bundle! "gem foobar" do |input, _, _|
+ input.puts "github"
+ end
+
+ expect(bundled_app("foobar/.github/workflows/main.yml")).to exist
+ end
+
it "asks about MIT license" do
- global_config "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false"
+ global_config "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__RUBOCOP" => "false"
bundle "config list"
@@ -888,7 +986,7 @@ Usage: "bundle gem NAME [OPTIONS]"
end
it "asks about CoC" do
- global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false"
+ global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__RUBOCOP" => "false"
bundle! "gem foobar" do |input, _, _|
input.puts "yes"