Rails - How do you test ActionMailer sent a specific email in tests

后端 未结 7 2041
面向向阳花
面向向阳花 2020-12-23 12:58

Currently in my tests I do something like this to test if an email is queued to be sent

assert_difference(\'ActionMailer::Base.deliveries.size\', 1) do              


        
7条回答
  •  不知归路
    2020-12-23 13:27

    The test framework shoulda has an excellent helper which lets you assert certain conditions about an email that was sent. Yes, you could do it yourself with ActionMailer.deliveries, but shoulda makes it all one neat little block

提交回复
热议问题