Class: RuboCop::Cop::RSpecRails::MinitestAssertions::PredicateAssertion

Inherits:
BasicAssertion
  • Object
show all
Defined in:
lib/rubocop/cop/rspec_rails/minitest_assertions.rb

Overview

:nodoc:

Constant Summary collapse

MATCHERS =
%i[
  assert_predicate
  assert_not_predicate
  refute_predicate
].freeze

Instance Attribute Summary

Attributes inherited from BasicAssertion

#actual, #expected, #failure_message

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BasicAssertion

#initialize, #negated?, #replaced

Constructor Details

This class inherits a constructor from RuboCop::Cop::RSpecRails::MinitestAssertions::BasicAssertion

Class Method Details

.match(subject, predicate, failure_message) ⇒ Object



198
199
200
201
202
# File 'lib/rubocop/cop/rspec_rails/minitest_assertions.rb', line 198

def self.match(subject, predicate, failure_message)
  return nil unless predicate.value.end_with?('?')

  new(predicate, subject, failure_message.first)
end

.minitest_assertion(node) ⇒ Object



194
195
# File 'lib/rubocop/cop/rspec_rails/minitest_assertions.rb', line 194

def_node_matcher 'self.minitest_assertion', <<~PATTERN # rubocop:disable InternalAffairs/NodeMatcherDirective
(send nil? {:assert_predicate :assert_not_predic

Instance Method Details

#assertionObject



204
205
206
# File 'lib/rubocop/cop/rspec_rails/minitest_assertions.rb', line 204

def assertion
  "be_#{expected.delete_prefix(':').delete_suffix('?')}"
end