# Routes in Functional Tests?

**URL:** <https://www.ruby-forum.com/t/routes-in-functional-tests/128001>\
**Category:** Rails\
**Created:** [February 4, 2008, 4:58am UTC](https://www.ruby-forum.com/t/routes-in-functional-tests/128001 "2008-02-04T04:58:02Z")\
**Posts on this page:** 2\
**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 4, 2008, 4:58am UTC](https://www.ruby-forum.com/t/routes-in-functional-tests/128001/1 "2008-02-04T04:58:02Z")

</div>

Hello Rails Talk,

How do I get named routes in my functional tests? I am testing a  
mailer and want to check for a URL in the email:

:: user\_mailer\_test.rb ::  
require File.dirname( **FILE** ) + ‘/…/test\_helper’  
require ‘user\_mailer’

class UserMailerTest \< Test::Unit::TestCase

# FIXTURES\_PATH = File.dirname( **FILE** ) + ‘/…/fixtures’

CHARSET = “utf-8”

include ActionMailer::Quoting

def setup  
ActionMailer::Base.delivery\_method = :test  
ActionMailer::Base.perform\_deliveries = true  
ActionMailer::Base.deliveries = []  
@expected = TMail::Mail.new  
@expected.set\_content\_type “text”, “plain”, { “charset” =\>  
CHARSET }  
end

def test\_confirmation\_sent  
user = create\_user  
email = UserMailer.create\_signup\_notification(user)  
assert\_match(‘http://#{HOST}/’ +  
@controller.activate\_path(user.activation\_code), email.body)  
end  
end

Regards,  
–Dean

---

<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 4, 2008, 5:03am UTC](https://www.ruby-forum.com/t/routes-in-functional-tests/128001/2 "2008-02-04T05:03:18Z")

</div>

Forgot to say that this test fails like this:

1. Error:  
test\_confirmation\_sent(BrewerMailerTest):  
NoMethodError: You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.activate\_path  
./test/functional/brewer\_mailer\_test.rb:21:in  
`test\_confirmation\_sent’

Regards,  
–Dean
