2

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 <{"controller"=>"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.

1 Answer 1

4

Have you tried this?:

assert_routing({ :path => "invoices", :method => :post }, 
  { :controller => "invoices", :action => "create" })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.