Class: RuboCop::Cop::Minitest::NonExecutableTestMethod
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Minitest::NonExecutableTestMethod
- Includes:
- RuboCop::Cop::MinitestExplorationHelpers
- Defined in:
- lib/rubocop/cop/minitest/non_executable_test_method.rb
Overview
Checks for the use of test methods outside of a test class.
Test methods should be defined within a test class to ensure their execution.
NOTE: This cop assumes that classes whose superclass name includes the word
"Test" are test classes, in order to prevent false positives.
Constant Summary collapse
- MSG =
'Test method should be defined inside a test class to ensure execution.'
Constants included from RuboCop::Cop::MinitestExplorationHelpers
RuboCop::Cop::MinitestExplorationHelpers::ASSERTION_PREFIXES, RuboCop::Cop::MinitestExplorationHelpers::BLOCK_MATCHERS, RuboCop::Cop::MinitestExplorationHelpers::LIFECYCLE_HOOK_METHODS, RuboCop::Cop::MinitestExplorationHelpers::LIFECYCLE_HOOK_METHODS_IN_ORDER, RuboCop::Cop::MinitestExplorationHelpers::MATCHER_METHODS, RuboCop::Cop::MinitestExplorationHelpers::VALUE_MATCHERS
Instance Method Summary collapse
Instance Method Details
#on_def(node) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/rubocop/cop/minitest/non_executable_test_method.rb', line 32 def on_def(node) return if !test_method?(node) || !use_test_class? return if inside_test_class?(node) return if (node.left_siblings + node.right_siblings).none? { |sibling| possible_test_class?(sibling) } add_offense(node) end |