[rspec-users] Testing routes with a prefix

Justin Ko jko170 at gmail.com
Wed Mar 23 03:04:27 EDT 2011


On Tue, Mar 22, 2011 at 6:50 PM, Radhesh Kamath <lists at ruby-forum.com>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(...)
>
> Thanks,
> Radhesh
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


You're mapping absolute strings (URL's) to your routes. Any string
manipulation would dilute the spec. In my opinion, this is not a case of
keeping things DRY.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20110323/2e0eb2a4/attachment.html>


More information about the rspec-users mailing list