Tim Scott
Tim Scott

Reputation: 15205

Chain should_receive Possible?

Is there a more terse way to write this rspec code?

mailer = double
AdminMailer.should_receive(:request_failed).with(@request).and_return(mailer)
mailer.should_receive(:deliver)

I'm envisioning something like this:

AdminMailer
  .should_receive(:request_failed)
  .with(@request)
  .should_receive(:deliver)

Upvotes: 4

Views: 2046

Answers (1)

Wally Altman
Wally Altman

Reputation: 3545

I don't think it's possible, but even if it is, I wouldn't recommend it. Your specs should clearly show what you are expecting of your code, and your first example already does that quite succinctly!

Upvotes: 1

Related Questions