# Routes in Functional Tests?

**URL:** <https://www.ruby-forum.com/t/routes-in-functional-tests/196591>\
**Category:** Rails\
**Created:** [February 6, 2008, 4:05am UTC](https://www.ruby-forum.com/t/routes-in-functional-tests/196591 "2008-02-06T04:05:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dean](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3be4f8/32.png) [@dean](https://www.ruby-forum.com/u/dean)\
**Post date:** [February 6, 2008, 4:05am UTC](https://www.ruby-forum.com/t/routes-in-functional-tests/196591/1 "2008-02-06T04:05:48Z")

</div>

I have the following:

:: generic\_controller.rb ::

class GenericController \< ApplicationController  
def activate  
end

def index  
end  
end

:: routes.rb ::

ActionController::Routing::Routes.draw do |map|  
map.activate ‘/activate/:activation\_code’, :controller =\>  
‘generic’, :action =\> ‘activate’  
end

:: generic\_controller\_test.rb ::

require File.dirname( **FILE** ) + ‘/…/test\_helper’

class GenericControllerTest \< ActionController::TestCase  
def test\_activate\_path  
get :index  
assert\_not\_nil activate\_path(“something”)  
end  
end

0 remus test/functional % ruby generic\_controller\_test.rb  
Loaded suite generic\_controller\_test  
Started  
.  
Finished in 0.280308 seconds.  
1 tests, 1 assertions, 0 failures, 0 errors

If I comment out the get :index call in my test file, I get this:

0 remus test/functional % ruby generic\_controller\_test.rb  
Loaded suite generic\_controller\_test  
Started  
E  
Finished in 0.282201 seconds.

1. Error:  
test\_activate\_path(GenericControllerTest):  
NoMethodError: You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.rewrite  
/usr/lib64/ruby/gems/1.8/gems/actionpack-2.0.2/lib/  
action\_controller/base.rb:616:in `url_for' (eval):17:in`activate\_path’  
/usr/lib64/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action\_controller/  
test\_process.rb:463:in `send!' /usr/lib64/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ test_process.rb:463:in`method\_missing’  
generic\_controller\_test.rb:7:in `test_activate_path' /usr/lib64/ruby/gems/1.8/gems/activesupport-2.0.2-/lib/active_support/ testing/default.rb:7:in`run’

What is it about the get call that “turns on” the named route?

Regards,  
–Dean
