Module: RuboCop::Cop::Vicenzo::RSpec::ExpectationTarget

Included in:
CompetingSubjects, SubjectDefinedAsLet
Defined in:
lib/rubocop/cop/vicenzo/rspec/mixin/expectation_target.rb

Overview

Shared helpers to tell which definitions an example group's expectations are about.

Only the left-hand side of an expectation counts - expect(order) and expect { order }. What sits inside the matcher is the expected answer, not the subject: in expect(described_class.recent).to contain_exactly(recent_order), recent_order is part of the answer, and reading it as the subject would turn the correct way of specifying a scope into an offense.

Meant for cops inheriting from RuboCop::Cop::RSpec::Base and including PremiseTracking: let?, example_group? and premise_name come from there.

Constant Summary collapse

EXPECTATION_RUNNERS =
i[to not_to to_not].freeze
MESSAGE_MATCHERS =

Verifying a message is a statement about a collaborator, never about the subject.

i[receive have_received receive_messages receive_message_chain].freeze