我无法测试我的邮件程序。似乎用描述为email-with-name格式的电子邮件分配属性 [:to, :from, :reply_to]不起作用。
这是一个简单的例子。
class MessageMailer < ActionMailer::Base
def simple
mail(
from: "Aaron Test <aaron@test.com>",
to: "Aaron Test <aaron@test.com>",
reply_to: "Aaron Test <aaron@test.com>"
)
end
end
message_mailer_spec.rb
EXPECTED = "Aaron Test <aaron@test.com>"
describe MessageMailer do
before do
@email = MessageMailer.simple
end
it "expect `from` to eq #{EXPECTED}" do
expect( @email.from ).to eq(EXPECTED)
end
it "expect `to` to eq #{EXPECTED}" do
expect( @email.to ).to eq(EXPECTED)
end
it "expect `reply_to` to eq #{EXPECTED}" do
expect( @email.reply_to ).to eq(EXPECTED)
end
end
测试结果都一样
1) MessageMailer expect `reply_to` to eq Aaron Test <aaron@test.com>
Failure/Error: expect( @email.reply_to ).to eq(EXPECTED)
expected: "Aaron Test <aaron@test.com>"
got: ["aaron@test.com"]
(compared using ==)
任何人都知道如何以 email-with-name 格式分配 [to:, from:, reply_to:] 吗?
我错过了什么吗?
是否有不同的方法来保存我可以测试的电子邮件标题?