【发布时间】:2009-07-16 14:22:51
【问题描述】:
我在我的环境/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"
但我不想以这种方式显式命名域 (我已经在我的环境/test.rb 文件中指定了它 - 这样它就不会干了)
【问题讨论】:
标签: ruby-on-rails ruby routing url-rewriting