这可能是一个非常基本的错误,但我仍然在学习。 =)简单路由RSpec控制器测试失败
我的routes.rb只包括
WebPortal::Application.routes.draw do
resources :categories
end
如果我理解正确这,这应该(等等)地图/categories
到CategoriesController.index
。该控制器看起来像
class CategoriesController < ApplicationController
def index
end
end
相应的视图文件存在,并且轨服务器为这一页罚款。但我的RSpec的测试
describe CategoriesController do
describe "GET :index" do
it "should be succesful" do
get :index
response.should be_succes
end
end
end
失败的消息
Failure/Error: get :index
ActionController::RoutingError:
No route matches {:controller=>"categories"}
我在做什么错在这里?
编辑:
rake routes
categories GET /categories(.:format) {:action=>"index", :controller=>"categories"}
POST /categories(.:format) {:action=>"create", :controller=>"categories"}
new_category GET /categories/new(.:format) {:action=>"new", :controller=>"categories"}
edit_category GET /categories/:id/edit(.:format) {:action=>"edit", :controller=>"categories"}
category GET /categories/:id(.:format) {:action=>"show", :controller=>"categories"}
PUT /categories/:id(.:format) {:action=>"update", :controller=>"categories"}
DELETE /categories/:id(.:format) {:action=>"destroy", controller=>"categories"}
当你在项目文件夹中运行“耙路”时,你会得到什么? – Rasmus
@Rasmus:我用输出编辑了我的问题。 – Jens
我自己还是个新人,我正在看一个简单的项目。我的代码和你的代码唯一的区别在于我的索引是'索引'而不是索引。但是我不认为会这样做 – Rasmus