Forum: Ruby on Rails name_url in tests

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dorian M. (Guest)
on 2006-05-09 08:08
(Received via mailing list)
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
    generated/routing/named_routes/taste.rb:2:in `taste_url'
    test/functional/films_controller_test.rb:92:in `test_routes'
Rob S. (Guest)
on 2006-07-22 12:36
(Received via mailing list)
On 5/8/06, Dorian M. <removed_email_address@domain.invalid> wrote:
>     test/functional/films_controller_test.rb:92:in `test_routes'
> --
> --
> I do things for love or money
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid

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
This topic is locked and can not be replied to.