Given a method and path, I want to ask Rails how that request would be routed, and i want to be able to do this from console, and/or from a rake task. I figure this should be straightforward - ActionDispatch does this for every request, and the route testing methods obviously also do it.
(Currently: Rails 3.0.x, but for the gem I'm writing I will need to be able to do this in Rails 3.0 through 4.1, at minimum, and possibly in older versions as well.)
I've been trying a few things like this:
routes = ActionDispatch::Routing::RouteSet.new
routes.recognize_path('/my/path/23/edit')
or
Rails.application.routes.recognize_path('/my/path/23/edit')
In both cases, I get back "RuntimeError: route set not finalized".
I'm diving through the ActionDispatch code working it out slowly, but if anyone knows the answer off the top of their head it would save me considerable time. So, thank you!