I have a form that is suppose to be a POST to CREATE action but it is doing a POST to INDEX action. So i then decided to test my routes with rspec. In my Example i have my test as follows.
it "should recognize a specific invoices#create route" do
assert_routing("/invoices", {:controller => "invoices", :action => "create"})
end
but when i run the test its coming up with this error.
1) InvoicesController on get to :index should recognize a specific invoices#create route
Failure/Error: assert_routing("/invoices", {:controller => "invoices", :action => "create"})
The recognized options <{"action"=>"index", "controller"=>"invoices"}> did not match <{"con开发者_如何学运维troller"=>"invoices", "action"=>"create"}>, difference: <{"action"=>"create"}>.
Expected block to return true value.
So im trying to figure out why my form is doing a POST on INDEX and why my test thinks im doing an index route. I have tried inserting :method => :post in the test but it doesnt seem to work.
Have you tried this?:
assert_routing({ :path => "invoices", :method => :post },
{ :controller => "invoices", :action => "create" })
精彩评论