Forum: Ruby on Rails testing named routes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dorian M. (Guest)
on 2006-05-08 22:23
(Received via mailing list)
Hello,
I'm trying to test routes named within a map.with_options statement.
I have in routes.rb:

  map.with_options :controller => 'films' do |f|
    f.overviews   'films/:index', :action => 'index', :requirements => {
:index => /index(artist|date|title)\.html/ }, :index => 'new'
    etc...
  end

and my test:
    opts = { :controller => "films", :action => "index", :index =>
"indexdate.html" }
    assert_routing overviews_url(:controller => "films", :index =>
"indexdate.html"), opts

which gives me:
  2) Error:
test_routes(FilmsControllerTest):
NoMethodError: You have a nil object when you didn't expect it!
The error occured while evaluating nil.rewrite
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:459:in
`url_for'
    generated/routing/named_routes/overviews.rb:2:in `overviews_url'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/test_process.rb:431:in
`send'
    /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/test_process.rb:431:in
`method_missing'
    functional/films_controller_test.rb:85:in `test_routes'

How can I reference a named route in map.with_options? or is this just
plain wrong :)

thanks

dorian

--
I do things for love or money
This topic is locked and can not be replied to.