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
Post a Comment