行动邮递员
def welcome_send(user)
@user = user
mail to: user.email, subject: 'Welcome to my site', from: 'suhasmv29@gmail.com'
end
Run Code Online (Sandbox Code Playgroud)
用于验证邮件已发送的 RSpec 测试用例
it "sends a confirmation email" do
expect { mail.to }.to change { ActionMailer::Base.deliveries.count }.by(1)
end
Run Code Online (Sandbox Code Playgroud)
错误
expected `ActionMailer::Base.deliveries.count` to have changed by 1, but was changed by 0
Run Code Online (Sandbox Code Playgroud) rspec ruby-on-rails actionmailer rspec-rails ruby-on-rails-4