Skip to content

Commit

Permalink
Ignore *Test named classes again
Browse files Browse the repository at this point in the history
  • Loading branch information
nvasilevski committed Jul 29, 2024
1 parent 962589d commit d4ccf20
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/spoom/deadcode/plugins/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 8 additions & 2 deletions test/spoom/deadcode/plugins/minitest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,15 +30,13 @@ 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
assert_ignored(index, "C1Test")
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
Expand Down

0 comments on commit d4ccf20

Please sign in to comment.