Absolute urls don't work in functional tests (with 'fix')

Why is it that I can't do "get posts_url" in my post functional testing? posts_url correctly evaluates to "http://test.host/posts" (*), but any attempt to get this url fails with an UnknownAction. Similarly, "get '/posts'", "get '/posts/index'" etc all fail. "get 'index'" works fine.

Which may sound trivial, but it seems silly to not be able to use "get new_post_url" with your restful controllers.

The main reason it's falling over seems to be that the TestProcess module is very action-based - it doesn't expect to see the full "http://test.host/posts/index" url. I've hacked in a workaround that strips out everything but the action:

module ActionController::TestProcess
   alias_method :orig_process, :process
   def process(action, parameters = nil, session = nil, flash = nil)
     #Strip out occurrences of (eg) ‘http://test.host/posts’, leaving us with just the action.
     nameless_action = action.to_s.gsub(/http:\/\/#{@request.host_with_port}\/#{@controller.class.controller_path}\/?/, ‘’)
     nameless_action = ‘index’ if nameless_action.blank?
     orig_process(nameless_action, parameters, session, flash)

- but it's pretty ugly, and I suspect it'll break on all but the simplest routes. Can anyone else do better?


* - once you've done the "get :index" hack - http://rails.techno-weenie.net/tip/2006/7/22/test-named-routes-or-url_for-link_to)

Hmph, well that doesn't work. It falls over on a number of restful things like post_url(@post) ("http://test.host/posts/6")

Any other bright ideas?