【发布时间】:2012-11-12 08:28:13
【问题描述】:
我刚刚使用 rspec-rails 2.11.4 升级到 Capybara 2.0.0.beta4,并且按照 RSpec-Rails 存储库中的 Capybara-Readme 的建议,我将我的请求规范(我只有一个)移动到了 spec/features。
当我现在运行测试时,它找不到任何路径。所以对于下面的测试块:
it "should be able to access the signup page through the front page" do
visit root_path
click_link "Signup For Free Now"
page.should have_content("Signup")
end
我收到错误消息:
Failure/Error: visit root_path
NameError: undefined local variable or method `root_path' for #<RSpec...>
当我尝试使用visit "/" 运行测试时,它工作正常。其他 gem 版本是:
- 导轨 3.2.1
- rspec 2.11.0
- 机架测试 0.6.2
对于路径问题的原因有什么想法吗?
【问题讨论】:
-
如果不使用rspec也可以添加命名路由:stackoverflow.com/questions/9475857/rspec-and-named-routes
标签: ruby-on-rails-3 capybara rspec-rails