1

私はこのリソースを持っていますconfig/routes.rb

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)>'

ユーザーにDevise2.0を使用しています。

このエラーを修正するにはどうすればよいですか?

4

1 に答える 1

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
于 2012-07-14T11:27:50.917 に答える