action_mailer_matchers
action_mailer_matchers copied to clipboard
Add `have_sent(number).emails` matcher
Add a matcher to check how many emails that have been sent as a result of an action.
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
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. 🎉
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.
Awesome! Looking forward to discussing it further with you.