Minitest and Routing

The primary method that Rails/Minitest uses for route testing is assert_routing. Here are the Minitest versions of the same standard routes:

minitest/01/gatherer/test/controllers/projects_controller_test.rb
​ 
test ​"routing"​ ​do​
​ 
assert_routing ​"/projects"​, controller: ​"projects"​, action: ​"index"​
​ 
assert_routing({path: ​"/projects"​, method: ​"post"​},
​ 
controller: ​"projects"​, action: ​"create"​)
​ 
assert_routing ​"/projects/new"​, controller: ​"projects"​, action: ​"new"​
​ 
assert_routing ​"/projects/1"​, controller: ​"projects"​,
​ 
action: ​"show"​, id: ​"1"​
​ 
assert_routing ​"/projects/1/edit"​, controller: ​"projects" ...

Get Rails 4 Test Prescriptions 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.