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:
| require "test_helper" |
| |
| class ProjectsControllerTest < ActionController::TestCase |
| 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: ... |
Get Rails 5 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.