summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/cli/gem.rb2
-rw-r--r--spec/bundler/commands/newgem_spec.rb96
2 files changed, 92 insertions, 6 deletions
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index a21b63e91a..749b3012d1 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -185,10 +185,12 @@ module Bundler
config[:linter_version] = rubocop_version
Bundler.ui.info "RuboCop enabled in config"
templates.merge!("rubocop.yml.tt" => ".rubocop.yml")
+ config[:ignore_files] << ".rubocop.yml"
when "standard"
config[:linter_version] = standard_version
Bundler.ui.info "Standard enabled in config"
templates.merge!("standard.yml.tt" => ".standard.yml")
+ config[:ignore_files] << ".standard.yml"
end
if config[:exe]
diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index 5560734198..10fe0bec52 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -29,6 +29,13 @@ RSpec.describe "bundle gem" do
expect(ignored).to include(path)
end
+ def refute_ignore_list_includes(path)
+ generated = bundled_app("#{gem_name}/#{gem_name}.gemspec").read
+ matched = generated.match(/^\s+f\.start_with\?\(\*%w\[(?<ignored>.*)\]\)$/)
+ ignored = matched[:ignored]&.split(" ")
+ expect(ignored).not_to include(path)
+ end
+
let(:generated_gemspec) { Bundler.load_gemspec_uncached(bundled_app(gem_name).join("#{gem_name}.gemspec")) }
let(:gem_name) { "mygem" }
@@ -188,6 +195,10 @@ RSpec.describe "bundle gem" do
it "generates a default .rubocop.yml" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to exist
end
+
+ it "includes .rubocop.yml into ignore list" do
+ assert_ignore_list_includes ".rubocop.yml"
+ end
end
end
@@ -217,6 +228,10 @@ RSpec.describe "bundle gem" do
it "doesn't generate a default .rubocop.yml" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to_not exist
end
+
+ it "does not add .rubocop.yml into ignore list" do
+ refute_ignore_list_includes ".rubocop.yml"
+ end
end
end
@@ -247,6 +262,10 @@ RSpec.describe "bundle gem" do
it "generates a default .rubocop.yml" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to exist
end
+
+ it "includes .rubocop.yml into ignore list" do
+ assert_ignore_list_includes ".rubocop.yml"
+ end
end
shared_examples_for "--linter=standard flag" do
@@ -274,6 +293,10 @@ RSpec.describe "bundle gem" do
it "generates a default .standard.yml" do
expect(bundled_app("#{gem_name}/.standard.yml")).to exist
end
+
+ it "includes .standard.yml into ignore list" do
+ assert_ignore_list_includes ".standard.yml"
+ end
end
shared_examples_for "--no-linter flag" do
@@ -311,9 +334,17 @@ RSpec.describe "bundle gem" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to_not exist
end
+ it "does not add .rubocop.yml into ignore list" do
+ refute_ignore_list_includes ".rubocop.yml"
+ end
+
it "doesn't generate a default .standard.yml" do
expect(bundled_app("#{gem_name}/.standard.yml")).to_not exist
end
+
+ it "does not add .standard.yml into ignore list" do
+ refute_ignore_list_includes ".standard.yml"
+ end
end
it "has no rubocop offenses when using --linter=rubocop flag" do
@@ -1172,30 +1203,51 @@ RSpec.describe "bundle gem" do
end
context "--linter with no argument" do
- it "does not generate any linter config" do
+ before do
bundle "gem #{gem_name}"
+ end
+ it "does not generate any linter config" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to_not exist
expect(bundled_app("#{gem_name}/.standard.yml")).to_not exist
end
+
+ it "does not add any linter config files into ignore list" do
+ refute_ignore_list_includes ".rubocop.yml"
+ refute_ignore_list_includes ".standard.yml"
+ end
end
context "--linter set to rubocop" do
- it "generates a RuboCop config" do
+ before do
bundle "gem #{gem_name} --linter=rubocop"
+ end
+ it "generates a RuboCop config" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to exist
expect(bundled_app("#{gem_name}/.standard.yml")).to_not exist
end
+
+ it "includes .rubocop.yml into ignore list" do
+ assert_ignore_list_includes ".rubocop.yml"
+ refute_ignore_list_includes ".standard.yml"
+ end
end
context "--linter set to standard" do
- it "generates a Standard config" do
+ before do
bundle "gem #{gem_name} --linter=standard"
+ end
+ it "generates a Standard config" do
expect(bundled_app("#{gem_name}/.standard.yml")).to exist
expect(bundled_app("#{gem_name}/.rubocop.yml")).to_not exist
end
+
+ it "includes .standard.yml into ignore list" do
+ assert_ignore_list_includes ".standard.yml"
+ refute_ignore_list_includes ".rubocop.yml"
+ end
end
context "--linter set to an invalid value" do
@@ -1210,30 +1262,49 @@ RSpec.describe "bundle gem" do
end
context "gem.linter setting set to none" do
- it "doesn't generate any linter config" do
+ before do
bundle "gem #{gem_name}"
+ end
+ it "doesn't generate any linter config" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to_not exist
expect(bundled_app("#{gem_name}/.standard.yml")).to_not exist
end
+
+ it "does not add any linter config files into ignore list" do
+ refute_ignore_list_includes ".rubocop.yml"
+ refute_ignore_list_includes ".standard.yml"
+ end
end
context "gem.linter setting set to rubocop" do
- it "generates a RuboCop config file" do
+ before do
bundle "config set gem.linter rubocop"
bundle "gem #{gem_name}"
+ end
+ it "generates a RuboCop config file" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to exist
end
+
+ it "includes .rubocop.yml into ignore list" do
+ assert_ignore_list_includes ".rubocop.yml"
+ end
end
context "gem.linter setting set to standard" do
- it "generates a Standard config file" do
+ before do
bundle "config set gem.linter standard"
bundle "gem #{gem_name}"
+ end
+ it "generates a Standard config file" do
expect(bundled_app("#{gem_name}/.standard.yml")).to exist
end
+
+ it "includes .standard.yml into ignore list" do
+ assert_ignore_list_includes ".standard.yml"
+ end
end
context "gem.rubocop setting set to true", bundler: "< 3" do
@@ -1247,6 +1318,10 @@ RSpec.describe "bundle gem" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to exist
end
+ it "includes .rubocop.yml into ignore list" do
+ assert_ignore_list_includes ".rubocop.yml"
+ end
+
it "unsets gem.rubocop" do
bundle "config gem.rubocop"
expect(out).to include("You have not configured a value for `gem.rubocop`")
@@ -1268,6 +1343,10 @@ RSpec.describe "bundle gem" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to exist
end
+ it "includes .rubocop.yml into ignore list" do
+ assert_ignore_list_includes ".rubocop.yml"
+ end
+
it "hints that --linter is already configured" do
expect(out).to match("rubocop is already configured, ignoring --linter flag.")
end
@@ -1319,6 +1398,11 @@ RSpec.describe "bundle gem" do
expect(bundled_app("#{gem_name}/.rubocop.yml")).to_not exist
expect(bundled_app("#{gem_name}/.standard.yml")).to_not exist
end
+
+ it "does not add any linter config files into ignore list" do
+ refute_ignore_list_includes ".rubocop.yml"
+ refute_ignore_list_includes ".standard.yml"
+ end
end
context "--edit option" do