I am working on a ruby on rails project, where I am trying to test the 'from' header field but the test case fails.
Here is what I am setting in the mailer action
def some_actoin
mail(to: [email protected],
from: '"Example" <[email protected]>',
subject: "test subject")
end
end
And in the rspec test case,
mail.from.should == '"Example" <[email protected]>'
My test case is failing with following error
expected: '"Example" <[email protected]>'
got: [[email protected]] (using ==)
Is is the wrong way to test from-header title with from-header email address?
Appreciates any help!
The mail.from
just contains the from email address. You'll want to test the display name too.
mail.from.should eq(['[email protected]'])
mail[:from].display_names.should eq(['Example'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With