How to test that a route does not exist in Rails 4.x -


if have route not defined, how test returns 404?

here relevant part of routes.rb

resources :reservations, only: [:index,:create,:destroy] 

you can create, destroy , list reservations, not change them.

the test is:

patch :update, id: @reservation, reservation: { somefield: "data" } assert_response :missing 

this should pass, since lack of route should return 404. instead, urlgenerationerror:

actioncontroller::urlgenerationerror: no route matches {:action=>"update", :controller=>"reservations", :id=>"980190962", :reservation=>{:somefield=>"data"}} 

i it; patch call test cannot generate url. how test such url call generate 404?

you assert error has been thrown, sufficient you?

assert_raise actioncontroller::urlgenerationerror   patch :update, id: @reservation, reservation: { somefield: "data" } end 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -