1

我目前正在用 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'

显然,最重要的是代码实际工作,并且它确实在浏览器中正确重定向,但我希望测试也能通过。有没有办法解决这个问题?

4

1 回答 1

0

你有没有解决过这个问题?我在 webrat 中的访问方法遇到了很多问题。结果证明在我的环境中有 RAILS_ENV=development。

于 2009-09-19T01:29:35.143 回答