Hiện tại, môi trường phát triển địa phương của tôi được thiết lập để có thể gửi email thực. Bởi vì điều này, việc giao hàng đang được thực hiện, và không có gì được giữ trong bảng ActionMailer::Base.deliveries
. Có thể vô hiệu hoá việc gửi email trong các bài kiểm tra dưa chuột không? Nếu vậy, cú pháp để làm điều này là gì? Hoặc có cách nào tốt hơn để kiểm tra email được gửi không?Có thể tắt email ActionMailer khi thử nghiệm dưa chuột đang diễn ra khi phát triển không?
authentication_steps.rb:
Then /^I should receive a confirmation email$/ do
email = ActionMailer::Base.deliveries.last
email.subject.should == "Welcome to our website!"
end
app/config/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']
}
...
Cảm ơn