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