[rspec-users] Speccing a redirect in routes

Chris Mear chrismear at gmail.com
Tue Aug 9 03:00:05 EDT 2011


On 9 Aug 2011, at 01:02, David Chelimsky wrote:

> On Aug 8, 2011, at 6:00 PM, Matt Wynne wrote:
> 
>> I expected to be able to do something like this in a routing spec:
>> 
>> { :get => '/legacy/route' }.should redirect_to('/shiny/new/route')
> 
> Routes resolve to paths to controller actions, they don't do any http redirection.

A 'redirect' helper was added to ActionDispatch::Mapper for Rails 3, to allow redirection without hitting a controller:

https://github.com/rails/rails/commit/a1ce52e#L2R294

http://guides.rubyonrails.org/routing.html#redirection

Chris



More information about the rspec-users mailing list