HTTP PUT

HTTP PUT (some frameworks like Rails use a similar verb called PATCH) is similar to POST. Only here, instead of creating a brand-new permit, we are going to update an existing one.

images/rest/put.png

If we go with a similar game plan to testing PUT as we did with POST, we can write a similar-looking test that looks something like this:

 test ​'HTTP PUT'​ ​do
 # search for permit by new attribute
  permit = Permit.find_by_location(​'Medicine Hat'​)
 
 # verify it doesn't exist
  assert_nil permit
 
 # update it
  put permit_path(@permit), ​permit: ​{​location: ​​'Medicine Hat'​}
 
 # search for it again
  permit = Permit.find_by_location(​

Get The Way of the Web Tester now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.