Saya mengalami masalah dalam menguji mailer saya. Tampaknya menetapkan atribut [:to, :from, :reply_to] dengan email dalam format yang dijelaskan sebagai email-dengan-nama tidak berfungsi.
Berikut adalah contoh sederhana.
class MessageMailer < ActionMailer::Base
def simple
mail(
from: "Aaron Test <[email protected]>",
to: "Aaron Test <[email protected]>",
reply_to: "Aaron Test <[email protected]>"
)
end
end
pesan_mailer_spec.rb
EXPECTED = "Aaron Test <[email protected]>"
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
Hasil tesnya semua sama
1) MessageMailer expect `reply_to` to eq Aaron Test <[email protected]>
Failure/Error: expect( @email.reply_to ).to eq(EXPECTED)
expected: "Aaron Test <[email protected]>"
got: ["[email protected]"]
(compared using ==)
Adakah yang tahu cara menetapkan [ke:, dari:, reply_to:] dalam format email dengan nama?
Apakah saya melewatkan sesuatu?
Apakah ada metode berbeda yang menyimpan header email yang dapat saya uji?