In Rails Controller tests of an invalid route, this used to work before Rails-7.1 (in Minitest):
assert_raises(ActionController::RoutingError){ get "/non_existent" }
In Rails-7.1 (or later), where the default value for config.action_dispatch.show_exceptions changes into :rescuable (see Official guide), as usually defined in /config/environments/test.rb, I need to modify it for the test to pass, as
get "/non_existent"
assert_response :missing # :not_found 404
However, I think the HTTP response of 404 can be raised by a different cause from RoutingError.
So, I still would like to test whether a given path is valid or not. Is there any low-level method in Rails-7.1 for it, which works regardless of the value of config.action_dispatch.show_exceptions? For example, something like the following would be ideal:
refute is_path_valid?("/non_existent", :get)
# or
assert_raises(ActionController::RoutingError){ examine_this_path("/non_existent", :get) }
I note that a temporal, on-the-spot change of config.action_dispatch.show_exceptions = :none while executing the test block would affect nothing, presumably because the config value is read once at boot and persists.