我正在尝试使用email_spec
使用rspec / capybara测试密码恢复我的test.rb包含:
config.action_mailer.delivery_method = :test
我的测试是这样的:
feature User do
let!(:user){ FactoryGirl.build(:user) }
before(:each) do
visit root_path
click_link "Sign up/in"
end
scenario "recover password" do
user.save!
click_link "Forgot password?"
fill_in "Email", :with => user.email
click_button "Send me reset password instructions"
unread_emails_for(user.email).should be_present
end
我的测试失败了:
1) User recover password
Failure/Error: click_button "Send me reset password instructions"
ActionView::Template::Error:
Missing host to link to! Please provide the :host parameter,
set default_url_options[:host], or set :only_path to true
如果我设置default_url_options,rspec会尝试发送邮件。我不太确定:only_path。
任何人都可以指出我正确的方向吗?非常感谢。
答案 0 :(得分:3)
在/config/environments/test.rb
:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }