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

前端 未结 2 676
自闭症患者
自闭症患者 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 02:55

    I had something similar where I wanted to check an attached csv's content. I needed something like this because it looks like \r got inserted for newlines:

    expect(mail.attachments.first.body.encoded.gsub(/\r/, '')).to(
      eq(
        <<~CSV
          "Foo","Bar"
          "1","2"
        CSV
      )
    ) 
    

提交回复
热议问题