Rails - How to test that ActionMailer sent a specific attachment?

前端 未结 2 683
自闭症患者
自闭症患者 2021-02-05 02:17

In my ActionMailer::TestCase test, I\'m expecting:

@expected.to      = BuyadsproMailer.group_to(campaign.agency.users)
@expected.subject = \"You submitted #{off         


        
2条回答
  •  长情又很酷
    2021-02-05 03:00

    Here's an example that I copied from my rspec test of a specific attachment, hope that it helps (mail can be creating by calling your mailer method or peeking at the deliveries array after calling .deliver):

      mail.attachments.should have(1).attachment
      attachment = mail.attachments[0]
      attachment.should be_a_kind_of(Mail::Part)
      attachment.content_type.should be_start_with('application/ics;')
      attachment.filename.should == 'event.ics'
    

提交回复
热议问题