Name_url in tests

Hi there,
I posted earlier asking about testing named routes in functional tests,
but got no response, so I’m making my question less specific.

It seems from the docs that it’s possible to to test named routes in
cases such as:
asserts_redirect_to name_url(:param => “whatever”)

but I haven’t seen any mention of it being used with any other tests and
I keep getting an error when I try and use it in assert_recognizes (see

Is there anything in particular I have to do to get the _url
functionality imported into my tests?
I’m using rails 1.1.2

thanks for any pointers in the dark-arts of URL rewriting tests.



# named routes
opts = { :action => "dotest", :test => "test1" }
assert_recognizes opts, taste_url(:action => "dotest", :test => 


Error ( I have a route named ‘taste’):

NoMethodError: You have a nil object when you didn’t expect it!
The error occured while evaluating nil.rewrite
url_for' generated/routing/named_routes/taste.rb:2:intaste_url’
send' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/test_process.rb:431:inmethod_missing’
test/functional/films_controller_test.rb:92:in `test_routes’

On 5/8/06, Dorian M. [email protected] wrote:

test/functional/films_controller_test.rb:92:in `test_routes'

I do things for love or money

Rails mailing list
[email protected]

Hi Dorian,

I realize this is a late reply, but I ran into the same issue with
testing named routes. This might help you:

  • Rob