Sha256: e611b6b5aa59bb95c618c6e85bc313e5ca0b9d48d8a79602cdd8b57779b053dd
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module RuboCop module Cop module Minitest # Enforces the test to use `assert_silent { ... }` # instead of using `assert_output('', '') { ... }`. # # @example # # bad # assert_output('', '') { puts object.do_something } # # # good # assert_silent { puts object.do_something } # class AssertSilent < Base extend AutoCorrector MSG = 'Prefer using `assert_silent`.' def_node_matcher :assert_silent_candidate?, <<~PATTERN (block (send nil? :assert_output #empty_string? #empty_string?) ...) PATTERN def on_block(node) return unless assert_silent_candidate?(node) send_node = node.send_node add_offense(send_node) do |corrector| corrector.replace(send_node, 'assert_silent') end end private def empty_string?(node) node.str_type? && node.value.empty? end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems