lib/rubocop/cop/minitest/assert_path_exists.rb in rubocop-minitest-0.11.1 vs lib/rubocop/cop/minitest/assert_path_exists.rb in rubocop-minitest-0.12.0

- old
+ new

@@ -13,11 +13,13 @@ # # # good # assert_path_exists(path) # assert_path_exists(path, 'message') # - class AssertPathExists < Cop + class AssertPathExists < Base + extend AutoCorrector + MSG = 'Prefer using `%<good_method>s` over `%<bad_method>s`.' RESTRICT_ON_SEND = %i[assert].freeze def_node_matcher :assert_file_exists, <<~PATTERN (send nil? :assert @@ -30,20 +32,11 @@ assert_file_exists(node) do |path, failure_message| failure_message = failure_message.first good_method = build_good_method(path, failure_message) message = format(MSG, good_method: good_method, bad_method: node.source) - add_offense(node, message: message) - end - end - - def autocorrect(node) - assert_file_exists(node) do |path, failure_message| - failure_message = failure_message.first - - lambda do |corrector| - replacement = build_good_method(path, failure_message) - corrector.replace(node, replacement) + add_offense(node, message: message) do |corrector| + corrector.replace(node, good_method) end end end private