[rspec-users] Testing routes with a prefix

Pat Maddox patmaddox at me.com
Wed Mar 23 06:26:59 EDT 2011


On Mar 22, 2011, at 6:50 PM, Radhesh Kamath wrote:

> Hi experts,
> 
> I am trying to test routing in my application, where all routes are
> enclosed in a namespace like so:
> 
> scope 'v1' do
>  resource :blah end
>    collection do
>      something
>    end
>  end
> end
> 
> Is there a clean way to set 'v1' somewhere and just write my routing
> tests like so:
> 
> describe 'routing for blah' do
> it 'should invoke show when it receives /xyz' do
>  { :get => '/blah/xyz'}.should route_to(...)
> end
> end
> 
> i.e., I do not want to say
> { :get => 'v1/blah/xyz'}.should route_to(...)

I don't understand. The path '/blah/xyz' does not route to (...), so why would you write an example saying that it does?

Pat


More information about the rspec-users mailing list