Method: MiniTest::Rails::Expectations#assert_routing
- Defined in:
- lib/minitest/rails/expectations.rb
#assert_routing ⇒ Object
Expects that path and options match both ways; in other words, it verifies that path generates options and then that options generates path. This essentially combines assert_recognizes and assert_generates into one step.
The extras hash allows you to specify options that would normally be provided as a query string to the action. The message parameter allows you to specify a custom error message to display upon failure.
# Expect a basic route: a controller with the default action (index)
{ controller: 'home', action: 'index' }.must_route_for '/home'
# Test a route generated with a specific controller, action, and parameter (id)
{ controller: 'entries', action: 'show', id: 23 }.must_route_for '/entries/show/23'
# Expect a basic route (controller + default action), with an error message if it fails
{ controller: 'store', action: 'index' }.must_route_for '/store'
# Tests a route, providing a defaults hash
{id: "9", item: "square"}.must_route_for 'controller/action/9', {controller: "controller", action: "action"}, {}, {item: "square"}
# Tests a route with a HTTP method
{ controller: "product", action: "update", id: "321" }.must_route_for({ method: 'put', path: '/product/321' })
See also ActionController::TestCase#assert_routing See also ActionView::TestCase#assert_routing See also ActionDispatch::IntegrationTest#assert_routing
:method: must_route_for :call-seq: options.must_route_for(path, defaults={}, extras={}, message=nil)
307 |
# File 'lib/minitest/rails/expectations.rb', line 307 infect_an_assertion :assert_routing, :must_route_for |