Sha256: 214a0a522934dca237ca8a65fe5b9b3122fc6fcc368797a7252911bf483adac4
Contents?: true
Size: 966 Bytes
Versions: 37
Compression:
Stored size: 966 Bytes
Contents
# frozen_string_literal: true module RuboCop module Cop module Minitest # Checks for a specified error in `assert_raises`. # # @example # # bad # assert_raises { raise FooException } # assert_raises('This should have raised') { raise FooException } # # # good # assert_raises(FooException) { raise FooException } # assert_raises(FooException, 'This should have raised') { raise FooException } # class UnspecifiedException < Base MSG = 'Specify the exception being captured.' def on_block(block_node) node = block_node.send_node return unless node.method?(:assert_raises) add_offense(node) if unspecified_exception?(node) end private def unspecified_exception?(node) args = node.arguments args.empty? || (args.size == 1 && args[0].str_type?) end end end end end
Version data entries
37 entries across 37 versions & 2 rubygems