Tag: urlhelper

Rspec未定义的局部变量或方法root_path

我开始使用Rspec,但是当我运行bundle exec rspec我收到一个错误 /spec/requests/pages_spec.rb:20:in `block (2 levels) in ‘: undefined local variable or method `root_path’ for # (NameError) 我没有运行Spork或Guard,所以下面的问题不适用 未定义的局部变量或方法`root_path’(Rspec Spork Guard) 我在spec_helper.rb文件中添加了config.include Rails.application.routes.url_helpers ,但这没有帮助。 undefined局部变量或方法`root_path’Hartl的教程第5.3.2节 这是pages_spec.rb require ‘spec_helper’ describe “Pages” do describe “navigation” do def self.it_should_be_on(path_name, value=nil) before { visit path_name } it “should be on #{path_name}” do page.should have_link(‘Home’) page.should have_link(‘Inventory’) page.should have_link(‘FAQ’) […]