Class: RuboCop::Cop::Workit::RSpecMinitestAssertions
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Workit::RSpecMinitestAssertions
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/workit/rspec_minitest_assertions.rb
Overview
Check if using Minitest matchers.
Constant Summary collapse
- MSG =
"Use `%<prefer>s`."
- RESTRICT_ON_SEND =
%i[assert_equal refute_equal].freeze
Instance Method Summary collapse
Instance Method Details
#minitest_assertion(node) ⇒ Object
26 27 28 |
# File 'lib/rubocop/cop/workit/rspec_minitest_assertions.rb', line 26 def_node_matcher :minitest_assertion, <<-PATTERN (send nil? {:assert_equal :refute_equal} $_ $_ $_?) PATTERN |
#on_send(node) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/rubocop/cop/workit/rspec_minitest_assertions.rb', line 30 def on_send(node) minitest_assertion(node) do |expected, actual, | prefer = replacement(node, expected, actual, .first) add_offense(node, message: (prefer)) do |corrector| corrector.replace(node, prefer) end end end |