我教的是,隨着像我config/environments/test.rb
delivery_method = :test
的選項,同時運行我的Rspec的測試中,我應該不會收到任何郵件:爲什麼我的Rspec的測試實時發送郵件?
配置/環境/ test.rb:
config.action_mailer.delivery_method = :test
但在我測試,當我使用FactoryGirl創建用戶並且用戶有發送註冊通知的回撥時,將發送此電子郵件:
myspec.rb:
user = FactoryGirl.create(:user, :login => 'johndoe')
user_observer.rb:
class UserObserver < ActiveRecord::Observer
def after_create(user)
UserMailer.signup_notification(user).deliver
end
end
action_mailer.rb:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "...",
:port => "25",
:domain => "...",
:user_name => "...",
:password => "...",
:authentication => :plain
}
什麼可能是錯誤的?
我使用:
- 的Rails 3.2.2
- 的buildin的ActionMailer
- RSpec的擺幅
- FactoryGirl
- 衛隊
難道說,這'的ActionMailer :: Base.delivery_method =:smtp'口罩我在'環境/ test.rb'配置? – DiegoFrings 2012-03-15 15:43:29