# Accessing routes from tests

**URL:** <https://www.ruby-forum.com/t/accessing-routes-from-tests/152393>\
**Category:** Rails\
**Created:** [November 3, 2008, 2:15pm UTC](https://www.ruby-forum.com/t/accessing-routes-from-tests/152393 "2008-11-03T14:15:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidtl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/35a633/32.png) [@davidtl](https://www.ruby-forum.com/u/davidtl)\
**Post date:** [November 3, 2008, 2:15pm UTC](https://www.ruby-forum.com/t/accessing-routes-from-tests/152393/1 "2008-11-03T14:15:19Z")

</div>

Inspired by Railscasts #124 “Beta Invitations”  
([#124 Beta Invitations - RailsCasts](http://railscasts.com/episodes/124-beta-invitations)) I created a small  
invitation system. The episode doesn’t cover testing, so I’ve made some  
tests for the Mailer responsible for sending the invitations. The test  
looks like this:

def test\_invitation  
invitation = Invitation.create(:sender =\> users(:admin),  
:recipient\_email =\> “removed\_email\_address@domain.invalid”)  
signup\_url = “???”  
mail = InvitationMailer.create\_invitation(invitation, signup\_url)  
assert\_equal “Invitation: Join Fountain CMS site”, mail.subject  
assert\_equal invitation.recipient\_email, mail.to.first  
assert\_equal “removed\_email\_address@domain.invalid”, mail.from.first  
expected\_body = “You were invited to join Fountain CMS  
site.\n#{signup\_url}\n”  
assert\_equal expected\_body, mail.body  
invitation.destroy  
end

The test passes but as you can see, the local variable “signup\_url” is  
set to “???”. That basically means that I don’t know how to access my  
routes outside the controllers and views. How is that done?
