Class: RuboCop::Cop::Minitest::TestMethodName
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Minitest::TestMethodName
- Extended by:
- AutoCorrector
- Includes:
- DefNode, RuboCop::Cop::MinitestExplorationHelpers
- Defined in:
- lib/rubocop/cop/minitest/test_method_name.rb
Overview
Enforces that test method names start with ‘test_` prefix. It aims to prevent tests that aren’t executed by forgetting to start test method name with ‘test_`.
Constant Summary collapse
- MSG =
'Test method name should start with `test_` prefix.'
Constants included from RuboCop::Cop::MinitestExplorationHelpers
RuboCop::Cop::MinitestExplorationHelpers::ASSERTION_PREFIXES, RuboCop::Cop::MinitestExplorationHelpers::LIFECYCLE_HOOK_METHODS, RuboCop::Cop::MinitestExplorationHelpers::LIFECYCLE_HOOK_METHODS_IN_ORDER
Instance Method Summary collapse
Instance Method Details
#on_class(class_node) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rubocop/cop/minitest/test_method_name.rb', line 37 def on_class(class_node) return unless test_class?(class_node) class_def_nodes(class_node).each do |node| next unless offense?(node) test_method_name = node.loc.name add_offense(test_method_name) do |corrector| corrector.replace(test_method_name, "test_#{node.method_name}") end end end |