我正在尝试测试注册电子邮件(与设计一起发送),但我不断收到错误消息:
Net::SMTPServerBusy: 454 4.7.1 <model_spec@example.com>: Relay access denied
我正在使用 Capybara 运行 Rails 3.2.11,并且我(暂时)将我的 spec_helper.rb 和 test.rb 文件削减到最低限度,仍然出现上述错误。
spec_helper.rb:
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = false
end
end
Spork.each_run do
FactoryGirl.reload
end
测试.rb:
Upficial::Application.configure do
config.whiny_nils = true
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.delivery_method = :test
end
测试本身非常简单:
require 'spec_helper'
describe User do
it "sends a confirmation email" do
@user = FactoryGirl.create(:user, email: "model_spec@example.com", username: "model_spec")
@user.send_confirmation_instructions
ActionMailer::Base.deliveries.last.to.should == [@user.email]
end
end
无论我使用 guard/spork 还是使用 'rspec spec/models/user_spec.rb' 运行,我都会得到相同的结果;测试总是失败
Net::SMTPServerBusy: 454 4.7.1 <model_spec@example.com>: Relay access denied
关于应该更改哪些配置的任何想法(如果有的话)?