Testing named routes


#1

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:inoverviews_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:inmethod_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 :slight_smile:

thanks

dorian


I do things for love or money