這可能是一個非常基本的錯誤,但我仍然在學習。 =)簡單路由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