我创建了一个名为PolicyController的控制器,并将其路由嵌套为:
scope "/your"
resources :shops do
resources :policies
end
end
现在,当我尝试测试此控制器时,我不断收到此错误:
1) PoliciesController POST 'create' should be successful
Failure/Error: post 'create'
ActionController::RoutingError:
No route matches {:controller=>"policies", :action=>"create"}
# ./spec/controllers/policies_controller_spec.rb:7:in `block (3 levels) in <top (required)>'
不确定如何正确设置。非常感谢帮助。
编辑:忘记我的规格:
describe PoliciesController do
describe "POST 'create'" do
it "should be successful" do
post 'create'
response.should be_success
end
end
答案 0 :(得分:4)
你觉得这会起作用吗?
post :create, :shop_id => 1
绝对想在之前的街区创建一个新店铺。