2012-07-14 104 views
1

我有這個資源,我config/routes.rb誤碼測試路由使用RSpec

resources :users, :path => "u" do 
resources :boards, :controller => 'users/boards', :path => "collections" 
end 

在我spec/routing/boards_routing_spec.rb我有:

require "spec_helper" 

describe Users::BoardsController do 
    describe "routing" do 

    it "routes to #index" do 
     get("/u/:user_id/collections").should route_to("users/boards#index") 
    end 

    end 
end 

我得到了一個錯誤:

Failures: 

    1) Users::BoardsController routing routes to #index 
    Failure/Error: get("/u/:user_id/collections").should route_to("users/boards#index") 
     The recognized options <{"action"=>"index", "controller"=>"users/boards", "user_id"=>":user_id"}> did not match <{"controller"=>"users/boards", "action"=>"index"}>, difference: <{"user_id"=>":user_id"}>. 
     <{"controller"=>"users/boards", "action"=>"index"}> expected but was 
     <{"action"=>"index", "controller"=>"users/boards", "user_id"=>":user_id"}>. 
    # ./spec/routing/boards_routing_spec.rb:7:in `block (3 levels) in <top (required)>' 

我爲用戶使用Devise 2.0。

我該如何解決這個錯誤?

回答

2

錯誤固定:

require "spec_helper" 

describe Users::BoardsController do 
    describe "routing" do 

    it "routes to #index" do 
     get("/u/hyperrjas/collections").should route_to("users/boards#index", :user_id => "hyperrjas") 
    end 
end