lib/rubocop/cop/mixin/minitest_exploration_helpers.rb in rubocop-minitest-0.10.2 vs lib/rubocop/cop/mixin/minitest_exploration_helpers.rb in rubocop-minitest-0.10.3
- old
+ new
@@ -8,10 +8,19 @@
module MinitestExplorationHelpers
extend NodePattern::Macros
ASSERTION_PREFIXES = %w[assert refute].freeze
+ ASSERTION_METHODS = %i[
+ assert assert_empty assert_equal assert_in_delta assert_in_epsilon assert_includes assert_instance_of
+ assert_kind_of assert_match assert_nil assert_operator assert_output assert_path_exists assert_predicate
+ assert_raises assert_respond_to assert_same assert_send assert_silent assert_throws
+ refute refute_empty refute_equal refute_in_delta refute_in_epsilon refute_includes refute_instance_of
+ refute_kind_of refute_match refute_nil refute_operator refute_path_exists refute_predicate
+ refute_respond_to refute_same
+ ].freeze
+
LIFECYCLE_HOOK_METHODS = %i[
before_setup
setup
after_setup
before_teardown
@@ -72,9 +81,13 @@
end
def assertion?(node)
node.send_type? &&
ASSERTION_PREFIXES.any? { |prefix| node.method_name.to_s.start_with?(prefix) }
+ end
+
+ def assertion_method?(method_name)
+ ASSERTION_METHODS.include?(method_name)
end
def lifecycle_hook_method?(node)
node.def_type? && LIFECYCLE_HOOK_METHODS.include?(node.method_name)
end