5
目前,我的本地開發環境設置爲能夠發送實際的電子郵件。正因爲如此,交貨正在進行,ActionMailer::Base.deliveries
表中沒有任何信息。是否可以在黃瓜測試中禁用電子郵件發送?如果是這樣,那麼執行此操作的語法是什麼?或者有更好的方法來測試發送的電子郵件嗎?當開發黃瓜測試時,是否可以關閉ActionMailer電子郵件?
authentication_steps.rb:
Then /^I should receive a confirmation email$/ do
email = ActionMailer::Base.deliveries.last
email.subject.should == "Welcome to our website!"
end
應用程序/配置/ development.rb
...
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
# Setup for local testing of emails using gmail test account
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => 'smtp.sendgrid.net',
:port => 587,
:domain => ENV['MAIL_DOMAIN'],
:authentication => 'plain',
:enable_starttls_auto => true,
:user_name => ENV['MAIL_USERNAME'],
:password => ENV['MAIL_PASSWORD']
}
...
感謝