Class: RuboCop::Cop::Minitest::SkipEnsure
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Minitest::SkipEnsure
- Defined in:
- lib/rubocop/cop/minitest/skip_ensure.rb
Overview
Checks that code in an ensure block does not run when the test is skipped.
If skip is conditional, the ensure block must also be conditional,
using the negation of the skip condition so that it runs only when the test runs.
On the other hand, skip used inside a rescue clause is accepted,
because the ensure block may serve as teardown for resources created in the begin setup.
Constant Summary collapse
- MSG =
'`ensure` is called even though the test is skipped.'
Instance Method Summary collapse
Instance Method Details
#on_ensure(node) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/rubocop/cop/minitest/skip_ensure.rb', line 68 def on_ensure(node) skip = find_skip(node) return if skip.nil? || use_skip_in_rescue?(skip) || valid_conditional_skip?(skip, node) add_offense(node.loc.keyword) end |