beam-community / bamboo

Testable, composable, and adapter based Elixir email library for devs that love piping.
https://hex.pm/packages/bamboo
MIT License
1.9k stars 343 forks source link

Assertions are destructive #632

Open kaikuchn opened 2 years ago

kaikuchn commented 2 years ago

Hey there,

I just started using this mail client, and it works like a charm! Thank you all for your hard work :) One thing that really surprised me during integration testing is that the assertions are destructive. I.e., the following code works as expected when you've sent one e-mail.

# deliver email
Mail.deliver_later()
# email was delivered, so the inner assertion raises
assert_raise(ExUnit.AssertionError, fn -> assert_no_emails_delivered() end)
# however, now there are no more delivered emails, so this does not raise
assert_no_emails_delivered()

It would be nice if this behaviour was documented. Personally I believe that problems like ordering the assertions (see https://github.com/thoughtbot/bamboo/issues/433) would not exist if the assertions would not be destructive. But that would be a breaking change :)

Thanks again for your hard work, let me know if you want me to prepare a pull request for the docs.

Best, Kai