Spies are an alternate type of test double that support this pattern by allowing you to expect that a message has been received after the fact, using have_received.
RSpec.describe "have_received" do
it "passes when the message has been received" do
invitation = spy('invitation')
invitation.deliver
expect(invitation).to have_received(:deliver)
end
end
RSpec.describe "have_received" do
it "passes when the message has been received" do
# omitted code
expect_any_instance_of(Invitation).to receive(:have_received)
post create, params
expect(response.status).to eq(302)
end
end