# Booting rails routing without a controller call

**URL:** <https://www.ruby-forum.com/t/booting-rails-routing-without-a-controller-call/148423>\
**Category:** RSpec\
**Created:** [September 12, 2008, 6:18pm UTC](https://www.ruby-forum.com/t/booting-rails-routing-without-a-controller-call/148423 "2008-09-12T18:18:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [September 12, 2008, 6:18pm UTC](https://www.ruby-forum.com/t/booting-rails-routing-without-a-controller-call/148423/1 "2008-09-12T18:18:20Z")

</div>

We’re getting into some quite complex routing, and I’d like to be  
able to spec the routing on its own.

All our controllers tend to have a little call to like this to boot  
up the routing before testing params\_from etc:

get :index

However I can’t get this to work in a spec that doesn’t start with  
describe SomeController.

Does anyone know how to get the routing loaded up without actually  
calling a controller?

## cheers, Matt

[http://blog.mattwynne.net](http://blog.mattwynne.net)

> **[Find the Best Concerts Near You, Tour Dates & Tickets Worldwide | Songkick](https://www.songkick.com/)**
>
> Find live music near you, track your favorite artists, get instant concert alerts and buy tickets for all the best upcoming concerts.

In case you wondered: The opinions expressed in this email are my own  
and do not necessarily reflect the views of any former, current or  
future employers of mine.

---

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [September 13, 2008, 3:00am UTC](https://www.ruby-forum.com/t/booting-rails-routing-without-a-controller-call/148423/2 "2008-09-13T03:00:53Z")

</div>

Worked perfectly, thank you.

By moving our routes config into lib/routing/default\_routes.rb, I can  
also get autotest to watch the file for changes - double bonus!

On 12 Sep 2008, at 17:21, David C. wrote:

> > describe  
> > end  
> > employers  
> > rspec-users mailing list  
> > [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > [http://rubyforge.org/mailman/listinfo/rspec-users](http://rubyforge.org/mailman/listinfo/rspec-users)

## cheers, Matt

> **[Tea-Driven Development – Matt Wynne taking it one tea at a time](http://blog.mattwynne.net)**

> **[Find the Best Concerts Near You, Tour Dates & Tickets Worldwide | Songkick](https://www.songkick.com/)**
>
> Find live music near you, track your favorite artists, get instant concert alerts and buy tickets for all the best upcoming concerts.

In case you wondered: The opinions expressed in this email are my own  
and do not necessarily reflect the views of any former, current or  
future employers of mine.

---

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [September 12, 2008, 6:23pm UTC](https://www.ruby-forum.com/t/booting-rails-routing-without-a-controller-call/148423/3 "2008-09-12T18:23:01Z")

</div>

On Fri, Sep 12, 2008 at 11:17 AM, Matt W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> We’re getting into some quite complex routing, and I’d like to be able to  
> spec the routing on its own.  
> All our controllers tend to have a little call to like this to boot up the  
> routing before testing params\_from etc:  
> get :index  
> However I can’t get this to work in a spec that doesn’t start with describe  
> SomeController.  
> Does anyone know how to get the routing loaded up without actually calling a  
> controller?

Should work if the file lives in spec/controllers. If not, you can do  
this:

describe “blah routing”, :type =\> :controller do  
..  
end
