目前在我的开发环境中,使用后我没有看到ActionMailer::Base.deliveries表中的任何内容mail.我缺少一个设置吗?
config/environments/development.rb :
config.action_mailer.delivery_method = :test.
应用程序/邮寄者/ notifier.rb
def send_email(user)
mail(:to => user.email, :subject => "Welcome to our website!")
end
Run Code Online (Sandbox Code Playgroud)
这些是我正在运行的测试:
When /^I signup$/ do
visit signup_path
@user = FactoryGirl.build(:user)
fill_in "user_email", :with => @user.email
fill_in "user_password", :with => @user.password
click_button "Join now"
end
Then /^I should receive a confirmation email$/ do
email = ActionMailer::Base.deliveries.last
email.subject.should == "Welcome to our website!"
end
Run Code Online (Sandbox Code Playgroud)
现在我得到以下错误I should receive a confirmation email:
undefined method subject for nil:NilClass (NoMethodError)
谢谢!
小智 10
另一种可能是在config/environments/test.rb中你有
config.action_mailer.delivery_method = :test
Run Code Online (Sandbox Code Playgroud)
但你已经设定好了
config.action_mailer.perform_deliveries = false
Run Code Online (Sandbox Code Playgroud)
所以改为
config.action_mailer.perform_deliveries = true
Run Code Online (Sandbox Code Playgroud)
在我的情况下让它再次起作用.
| 归档时间: |
|
| 查看次数: |
2481 次 |
| 最近记录: |