# Testing routes and controller results

**URL:** <https://www.ruby-forum.com/t/testing-routes-and-controller-results/103396>\
**Category:** Rails\
**Created:** [May 5, 2007, 3:59am UTC](https://www.ruby-forum.com/t/testing-routes-and-controller-results/103396 "2007-05-05T03:59:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![magic\_hat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5daacb/32.png) [@magic\_hat](https://www.ruby-forum.com/u/magic_hat)\
**Post date:** [May 5, 2007, 3:59am UTC](https://www.ruby-forum.com/t/testing-routes-and-controller-results/103396/1 "2007-05-05T03:59:10Z")

</div>

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:in`date\_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:in`test\_show\_title’
