我在environments/test.rb中指定了default_url_options:
config.action_mailer.default_url_options = { :host => "www.xyu.at" }
这很好,在我的黄瓜测试故事中,我测试用户注册时,用户激活链接会被正确生成。
invitation_activation_url(1)
=> "www.xyu.at/signup/1231hj23jh23"
当我尝试使用features/steps/user_steps.rb文件中的以下代码(使用来自http://github.com/bmabey/email-spec/tree/master的email-rspec)跟进电子邮件中提供的链接时:
When /^I follow the invitation link$/ do
When 'I follow "'+invitation_activation_url(1) + '" in the email'
end
这里使用默认主机创建了URL:
invitation_activation_url(1)
=> "www.example.com/signup/1231hj23jh23"
有谁能帮助我吗?我不知道我做错了什么....
谢谢!
编辑:
这似乎与方法有关
current_url
但是我不知道它来自哪里..?
编辑:
而且我在我的features/support/env.rb中指定了正确的环境。
ENV["RAILS_ENV"] ||= "test"
编辑:
我的临时解决方案是,就像edbond所说的那样,
invitation_activation_url(1, :host => "www.xyz.at")
=> "www.xyz.at/signup/1231hj23jh23"
但我不想以这种方式显式地命名域名(我已经在我的 environments/test.rb 文件中指定了它 - 这样就不会变得单调乏味)