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 ‘ensure` call even if `skip`. It is unexpected that `ensure` will be called when skipping test. If conditional `skip` is used, it checks that `ensure` is also called conditionally.
On the other hand, it accepts ‘skip` used in `rescue` because `ensure` may be teardown process to `begin` setup process.
Constant Summary collapse
- MSG =
'`ensure` is called even though the test is skipped.'
Instance Method Summary collapse
Instance Method Details
#on_ensure(node) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/rubocop/cop/minitest/skip_ensure.rb', line 67 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 |