From e1da5bf17d0c64938f1db335cc7768ab7292a888 Mon Sep 17 00:00:00 2001 From: Nikita Vasilevsky Date: Mon, 29 Jul 2024 12:59:15 -0400 Subject: [PATCH] Ignore `*Test` named classes again (#593) --- lib/spoom/deadcode/plugins/minitest.rb | 1 + test/spoom/deadcode/plugins/minitest_test.rb | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/spoom/deadcode/plugins/minitest.rb b/lib/spoom/deadcode/plugins/minitest.rb index 520928bd..36dfec67 100644 --- a/lib/spoom/deadcode/plugins/minitest.rb +++ b/lib/spoom/deadcode/plugins/minitest.rb @@ -7,6 +7,7 @@ module Plugins class Minitest < Base extend T::Sig + ignore_classes_named(/Test$/) ignore_classes_inheriting_from("Minitest::Test") MINITEST_METHODS = T.let( diff --git a/test/spoom/deadcode/plugins/minitest_test.rb b/test/spoom/deadcode/plugins/minitest_test.rb index a42e5db9..1b7009de 100644 --- a/test/spoom/deadcode/plugins/minitest_test.rb +++ b/test/spoom/deadcode/plugins/minitest_test.rb @@ -10,6 +10,14 @@ module Plugins class MinitestTest < TestWithProject include Test::Helpers::DeadcodeHelper + def test_ignores_test_class_based_on_name + @project.write!("foo_test.rb", <<~RB) + class FooTest < NotAMinitestClass; end + RB + + assert_ignored(index_with_plugins, "FooTest") + end + def test_ignore_minitest_classes_based_on_superclasses @project.write!("foo.rb", <<~RB) class C1Test < Minitest::Test; end @@ -22,7 +30,6 @@ class C2Test < ::Minitest::Test; end @project.write!("test/foo_test.rb", <<~RB) class C3Test < ::Minitest::Test; end class C4Test < C3Test; end - class C5Test; end RB index = index_with_plugins @@ -30,7 +37,6 @@ class C5Test; end assert_ignored(index, "C2Test") assert_alive(index, "C3Test") assert_ignored(index, "C4Test") - refute_ignored(index, "C5Test") end def test_does_not_ignore_minitest_methods_if_not_in_minitest_test_subclass