Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testing rails rspec控制器测试操作控制器::路由错误_Testing_Rspec_Controller_Nested Routes - Fatal编程技术网

Testing rails rspec控制器测试操作控制器::路由错误

Testing rails rspec控制器测试操作控制器::路由错误,testing,rspec,controller,nested-routes,Testing,Rspec,Controller,Nested Routes,我的路线是这样的 resources :stores, :except => [:destroy] do resources :toys, :member => {:destroy => :delete} end require 'spec_helper' describe ToysController do describe "GET index" do it "assigns all toys as @toys" do

我的路线是这样的

  resources :stores, :except => [:destroy] do
    resources :toys, :member => {:destroy => :delete}
  end
require 'spec_helper'

describe ToysController do

    describe "GET index" do
        it "assigns all toys as @toys" do
          toy11 = Factory(:toy, :is_shiny => true)
          toy12 = Factory(:toy,:is_shiny => false)
          get :index
          assigns(:toys).should eq([toy12,toy11 ])
        end
      end
    end
end
我的对象控制器规格如下所示

  resources :stores, :except => [:destroy] do
    resources :toys, :member => {:destroy => :delete}
  end
require 'spec_helper'

describe ToysController do

    describe "GET index" do
        it "assigns all toys as @toys" do
          toy11 = Factory(:toy, :is_shiny => true)
          toy12 = Factory(:toy,:is_shiny => false)
          get :index
          assigns(:toys).should eq([toy12,toy11 ])
        end
      end
    end
end
我犯了以下错误

 Failure/Error: get :index
 ActionController::RoutingError:
 No route matches {:controller=>"toys"}
由于toys资源嵌套在stores资源下,因此无法获取toys_路径路径,因此我认为规范失败了

我如何通过规范


谢谢

此错误是由于未将存储id发送到tyos索引。 我有没有发过信

:store_id => @store.id in get :index
它会过去的