新手问题 Rails 中 TDD 中的问题

hyanwang · 2013年07月10日 · 最后由 hyanwang 回复于 2013年07月10日 · 2696 次阅读

使用rails generate integration_test static_pages生成的static_pages_spec.rb文件,代码中有

get static_pages_index_path
response.status.should be(200) 

但测试的时候提示没有 static_pages_index_path 方法?这个是什么情况?

F.

Failures:

  1) StaticPages GET /static_pages works! (now write some real specs)
     Failure/Error: get static_pages_index_path
     NameError:
       undefined local variable or method `static_pages_index_path' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007fba87318050>
     # ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in <top (required)>'

Finished in 0.10695 seconds
2 examples, 1 failure

Failed examples:

rspec ./spec/requests/static_pages_spec.rb:5 # StaticPages GET /static_pages works! (now write some real specs)

static_pages 不是 scaffold 生成的所以没有 rest 路由,所以找不到 index 路径。

现在不懂没关系,照教程继续敲,后面会说的。

可以通过 rake routes 查看当前项目的所有使用中的路由

需要 登录 后方可回复, 如果你还没有账号请 注册新账号