[rspec-users] GET a path in a controller spec

J. B. Rainsberger jbrainsberger at gmail.com
Mon Feb 1 19:30:13 EST 2010


On Sun, Jan 31, 2010 at 17:02, Nick Hoffman <lists at ruby-forum.com> wrote:
> One of my controller actions sends a redirect if the request URI begins
> with /foods/search
>
>  34  def search
>  35    return redirect_to "/#{params[:name]}" if
> request.request_uri.match /^\/foods\/search/
>
> Unfortunately, I can't figure out how to spec this.

Do you want to check that search redirects, or the algorithm for
computing the redirect path? I would probably check the algorithm
separately, then stub the algorithm to check the redirect.
-- 
J. B. (Joe) Rainsberger :: http://www.jbrains.ca ::
http://blog.thecodewhisperer.com
Diaspar Software Services :: http://www.diasparsoftware.com
Author, JUnit Recipes
2005 Gordon Pask Award for contribution to Agile practice :: Agile
2010: Learn. Practice. Explore.


More information about the rspec-users mailing list