[前][次][番号順一覧][スレッド一覧]

ruby-changes:62236

From: Utkarsh <ko1@a...>
Date: Wed, 15 Jul 2020 16:05:53 +0900 (JST)
Subject: [ruby-changes:62236] c44c7019b5 (master): [rubygems/rubygems] Add tests with different flag combinations

https://git.ruby-lang.org/ruby.git/commit/?id=c44c7019b5

From c44c7019b5b320d427b9cf560fdb7790fd5c775f Mon Sep 17 00:00:00 2001
From: Utkarsh Gupta <utkarsh@d...>
Date: Tue, 30 Jun 2020 22:08:54 +0530
Subject: [rubygems/rubygems] Add tests with different flag combinations

Since this PR was made because we missed checking
RuboCop offenses with different flags, therefore
adding tests so that all flag combinations are
tested.

Signed-off-by: Utkarsh Gupta <utkarsh@d...>

https://github.com/rubygems/rubygems/commit/d08250efc2

diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb
index 4180653..39a69fe 100644
--- a/spec/bundler/commands/newgem_spec.rb
+++ b/spec/bundler/commands/newgem_spec.rb
@@ -10,6 +10,15 @@ RSpec.describe "bundle gem" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/newgem_spec.rb#L10
     expect(bundled_app("#{gem_name}/lib/#{require_path}/version.rb")).to exist
   end
 
+  def bundle_exec_rubocop
+    prepare_gemspec(bundled_app(gem_name, "#{gem_name}.gemspec"))
+    rubocop_version = RUBY_VERSION > "2.4" ? "0.85.1" : "0.80.1"
+    gems = ["minitest", "rake", "rake-compiler", "rspec", "rubocop -v #{rubocop_version}", "test-unit"]
+    path = Bundler.feature_flag.default_install_uses_path? ? local_gem_path(:base => bundled_app(gem_name)) : system_gem_path
+    realworld_system_gems gems, :path => path
+    bundle "exec rubocop --config .rubocop.yml", :dir => bundled_app(gem_name)
+  end
+
   let(:generated_gemspec) { Bundler.load_gemspec_uncached(bundled_app(gem_name).join("#{gem_name}.gemspec")) }
 
   let(:gem_name) { "mygem" }
@@ -174,17 +183,6 @@ RSpec.describe "bundle gem" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/newgem_spec.rb#L183
     it "generates a default .rubocop.yml" do
       expect(bundled_app("#{gem_name}/.rubocop.yml")).to exist
     end
-
-    it "runs rubocop inside the generated gem with no offenses" do
-      skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
-      prepare_gemspec(bundled_app(gem_name, "#{gem_name}.gemspec"))
-      rubocop_version = RUBY_VERSION > "2.4" ? "0.85.1" : "0.80.1"
-      gems = ["rake", "rubocop -v #{rubocop_version}"]
-      path = Bundler.feature_flag.default_install_uses_path? ? local_gem_path(:base => bundled_app(gem_name)) : system_gem_path
-      realworld_system_gems gems, :path => path
-      bundle "exec rubocop --config .rubocop.yml", :dir => bundled_app(gem_name)
-      expect(err).to be_empty
-    end
   end
 
   shared_examples_for "--no-rubocop flag" do
@@ -214,6 +212,41 @@ RSpec.describe "bundle gem" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/newgem_spec.rb#L212
     end
   end
 
+  it "has no rubocop offenses when using --rubocop flag" do
+    skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
+    bundle "gem #{gem_name} --rubocop"
+    bundle_exec_rubocop
+    expect(err).to be_empty
+  end
+
+  it "has no rubocop offenses when using --ext and --rubocop flag" do
+    skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
+    bundle "gem #{gem_name} --ext --rubocop"
+    bundle_exec_rubocop
+    expect(err).to be_empty
+  end
+
+  it "has no rubocop offenses when using --ext, --test=minitest, and --rubocop flag" do
+    skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
+    bundle "gem #{gem_name} --ext --test=minitest --rubocop"
+    bundle_exec_rubocop
+    expect(err).to be_empty
+  end
+
+  it "has no rubocop offenses when using --ext, --test=rspec, and --rubocop flag" do
+    skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
+    bundle "gem #{gem_name} --ext --test=rspec --rubocop"
+    bundle_exec_rubocop
+    expect(err).to be_empty
+  end
+
+  it "has no rubocop offenses when using --ext, --ext=test-unit, and --rubocop flag" do
+    skip "ruby_core has an 'ast.rb' file that gets in the middle and breaks this spec" if ruby_core?
+    bundle "gem #{gem_name} --ext --test=test-unit --rubocop"
+    bundle_exec_rubocop
+    expect(err).to be_empty
+  end
+
   shared_examples_for "CI config is absent" do
     it "does not create any CI files" do
       expect(bundled_app("#{gem_name}/.github/workflows/main.yml")).to_not exist
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]