我目前正在用Rails重写一个网站。我已经编写了一个将旧的静态URL映射到新的静态URL的模型,并且在应用程序控制器中,我捕获RoutingErrors以调用一个方法,该方法查找映射到旧的URL的新的URL。这在应用程序本身中工作得很好;如果我访问http://localhost:3000/home.htm,它会重定向到http://localhost:3000/home,但我无法获得我编写的要通过的Cucumber / Webrat测试,因为我总是收到这样的错误。
When I try to go to the old noticeboard
#features/step_definitions/redirection_steps.rb:7
No route matches "/noticeboard.htm" with {:method=>:get} (ActionController::RoutingError)
(eval):2:in `visit'
./features/step_definitions/redirection_steps.rb:8:in `/^I try to go to the old (.+)$/'
features/old_urls.feature:26:in `When I try to go to the old noticeboard'显然,最重要的是代码能正常工作,并且在浏览器中重定向是正确的,但我希望测试也能通过。有什么办法可以解决这个问题吗?
发布于 2009-09-19 01:29:35
你解决过这个问题吗?我对webrat中的访问方法有很多问题。事实证明,我的环境中包含了RAILS_ENV=development。
https://stackoverflow.com/questions/1179588
复制相似问题