Class: RuboCop::Cop::Minitest::RefutePathExists
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Minitest::RefutePathExists
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/minitest/refute_path_exists.rb
Overview
Enforces the test to use ‘refute_path_exists` instead of using `refute(File.exist?(path))`.
Constant Summary collapse
- MSG =
'Prefer using `%<good_method>s`.'
- RESTRICT_ON_SEND =
%i[refute].freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubocop/cop/minitest/refute_path_exists.rb', line 30 def on_send(node) refute_file_exists(node) do |path, | = .first good_method = build_good_method(node, path, ) = format(MSG, good_method: good_method) add_offense(node, message: ) do |corrector| corrector.replace(node.loc.selector, 'refute_path_exists') corrector.replace(node.first_argument, path.source) end end end |