Rails 3 - 如何摆脱“test.host”?
我最近安装了一个名为 Gretel 的插件来为我处理面包屑。它似乎工作得很好,除了它似乎违反了我的一些规范并出现以下错误:
Failure/Error: response.should redirect_to @course
Expected response to be a redirect to </courses/904> but was a redirect to
<http://test.host/courses/904>
我能做什么来摆脱这个错误?路径似乎完全正确,但有例外那个讨厌的 test.host 的事情。
I recently installed a plugin called Gretel to take care of breadcrumbs for me. It seems to be working great, except that it appears to be breaking some of my specs with the following error:
Failure/Error: response.should redirect_to @course
Expected response to be a redirect to </courses/904> but was a redirect to
<http://test.host/courses/904>
What can I do to get rid of this error? The path seems totally correct, with the exception of that pesky test.host thing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能正在针对 my_model_url 而不是 my_model_path 进行测试。
前者执行完整的 URI - 包括主机。后者是没有宿主的相对路径。
去检查你的控制器,看看它是否使用 _path 或 _url - 并在你的测试用例中使用相同的。
You are probably testing against my_model_url instead of my_model_path
The former does a full URI - including the host. The latter is a relative path without the host.
Go have a check in your controller and see if it uses _path or _url - and use the same one in your test-cases.
您需要明确定义您的请求主体..这里我有使用rails 3.0的应用程序...我正在使用Devise进行身份验证..并且我得到了用户指定的自定义域。
You need to expliclty define your request body..Here i have Application that uses rails 3.0...i am using Devise for authentication..and i get a customised domain that user specifies.