現在、私のローカル開発環境は、実際のメールを送信できるようにセットアップされています。このため、配達が行われており、ActionMailer::Base.deliveries
テーブルには何も保持されていません。cucumber テストでメール送信を無効にすることはできますか? もしそうなら、これを行うための構文は何ですか? または、送信されている電子メールをテストするより良い方法はありますか?
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']
}
...
ありがとう