This is supported in Edge but ActionMailbox::TestHelper 6.0.3.2 has not implemented it yet.
As a workaround, I came up with this:
subject do
mail = Mail.new do
to 'nicolas@test.lindsaar.net.au'
from 'Mikel Lindsaar <mikel@test.lindsaar.net.au>'
subject 'First multipart email sent with Mail'
text_part do
body 'Here is the attachment you wanted'
end
html_part do
content_type 'text/html; charset=UTF-8'
body '<h1>Funky Title</h1><p>Here is the attachment you wanted</p>'
end
add_file File.join(File.dirname(__FILE__), '../support/fixtures/image.jpeg')
end
# Tap the route for processing.
create_inbound_email_from_source(mail.to_s, status: :processing).tap(&:route)
end
If you're using edge or a newer version this should work:
receive_inbound_email_from_mail do |mail|
mail.to "David Heinemeier Hansson <david@loudthinking.com>"
mail.from "Bilbo Baggins <bilbo@bagend.com>"
mail.subject "Come down to the Shire!"
mail.text_part do |part|
part.body "Please join us for a party at Bag End"
end
mail.html_part do |part|
part.body "<h1>Please join us for a party at Bag End</h1>"
end
mail.add_file File.join(File.dirname(__FILE__), '../support/fixtures/image.jpeg')
end
Note: You'll need to change the file path to suit your needs. And receive_
methods are the same as create_
but they process the mail.