相关疑难解决方法(0)

RSpec找不到我的命名路线

我有一个莫名其妙的困难时间让我的命名路线在我的rspec测试中工作.

这就是我所看到的:

1) Home GET / works!
 Failure/Error: get root_path
 NameError:
   undefined local variable or method `root_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007fe13b0c1538>
 # ./spec/requests/home_spec.rb:6:in `block (3 levels) in <top (required)>'

2) Home GET / shows products!
 Failure/Error: get products_path
 NameError:
   undefined local variable or method `products_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007fe13b0cdea0>
 # ./spec/requests/home_spec.rb:10:in `block (3 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

规格/请求/ home_spec.rb

require 'spec_helper'

describe "Home" do
  describe "GET /" do
    it "works!" do
      get root_path
      response.status.should be(200)
    end
    it "shows products!" do
      get products_path
      response.status.should be(200) …
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails rails-routing ruby-on-rails-3

5
推荐指数
1
解决办法
1815
查看次数