action_mailer_matchers icon indicating copy to clipboard operation
action_mailer_matchers copied to clipboard

Add `have_sent(number).emails` matcher

Open aaackerman opened this issue 8 years ago • 4 comments

Add a matcher to check how many emails that have been sent as a result of an action.

aaackerman avatar Aug 15 '16 13:08 aaackerman

I think it would be a good idea to have an interface similar to Rspec Mocks. They are like this:

expect(...).to receive(...).once
expect(...).to receive(...).twice
expect(...).to receive(...).exactly(n).times
expect(...).to receive(...).at_least(:once)
expect(...).to receive(...).at_least(:twice)
expect(...).to receive(...).at_least(n).times
expect(...).to receive(...).at_most(:once)
expect(...).to receive(...).at_most(:twice)
expect(...).to receive(...).at_most(n).times

Maybe something that looks like:

expect {...}.to have_sent(n).email
expect {...}.to have_sent.exactly(n).emails
expect {...}.to have_sent.at_least(:one).email
expect {...}.to have_sent.at_least(:two).emails
expect {...}.to have_sent.at_least(n).emails
expect {...}.to have_sent.at_most(:one).email
expect {...}.to have_sent.at_most(:two).emails
expect {...}.to have_sent.at_most(n).emails

sophiedeziel avatar Sep 06 '16 22:09 sophiedeziel

Great suggestion, @sophiedeziel! I'll take a look at implementing one or two of those examples over the weekend. If you're interested in contributing too, please do! PRs are always welcome. 🎉

aaackerman avatar Sep 07 '16 13:09 aaackerman

Yes, I'd love to open a pull request for that! I wanted to discuss that interface with you first. I'll see if I have time to implement something today or tomorrow.

sophiedeziel avatar Sep 07 '16 14:09 sophiedeziel

Awesome! Looking forward to discussing it further with you.

aaackerman avatar Sep 07 '16 15:09 aaackerman