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
它会过去的