Testing routes and controller results

I’m trying to write a functional test that generates a route and then
follows that route to the controller and confirms that the appropriate
record is retrieved.

I’m getting some unexpected errors — I know the route works in
development mode – and wondering if anyone has an idea of what’s
happening here. Thanks for any help you can offer.

Here’s the test…

def test_show_title
@news=Article.find(1)
get date_url(:title=>"#{@news.srctitle}",
:section=>"#{@news.section.name}",
:year=>"#{@news.created_at.year}",
:month=>"#{@news.created_at.month}",
:day=>"#{@news.created_at.mday.to_s}")

end

and the error…

test_show_title(ArticlesControllerTest):
NoMethodError: You have a nil object when you didn’t expect it!
The error occured while evaluating nil.rewrite
/Applications/Locomotive2/Bundles/
rmagickRailsSept2006_x86.locobundle/framework/lib/ruby/gems/1.8/gems/
actionpack-1.12.5/lib/action_controller/base.rb:488:in url_for' generated/routing/named_routes/date.rb:2:indate_url’
/Applications/Locomotive2/Bundles/
rmagickRailsSept2006_x86.locobundle/framework/lib/ruby/gems/1.8/gems/
actionpack-1.12.5/lib/action_controller/test_process.rb:431:in
method_missing' ./test/functional/articles_controller_test.rb:33:intest_show_title’

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs