[rspec-users] params are making my "should redirect_to" test fail - why??

Rick DeNatale rick.denatale at gmail.com
Thu Feb 14 09:48:09 EST 2008


On 2/14/08, David Chelimsky <dchelimsky at gmail.com> wrote:
> On Thu, Feb 14, 2008 at 8:22 AM, Rick DeNatale <rick.denatale at gmail.com> wrote:
>  > On 2/14/08, Max Williams <toastkid.williams at gmail.com> wrote:

>  >  >  I've been looking for documentation for methods for the response object, to
>  >  > get the url, but i can't find any in the api docs (i'm probably just looking
>  >  > in the wrong place).  I can see the url data in the object but it's private.
>  >
>  >  Well the RedirectTo matcher gets it using
>  >
>  >     response.redirect_url
>  >
>  >  I'd probably write the check as
>  >
>  >    response.should be_redirect
>  >    response.redirect_url.should
>  >  match(%r{^http://test.host/admin/users/batch_saved(\?|$)})
>
>
> That seems reasonable given what is offered.
>
>  What do you guys think of a new matcher named redirect_with:
>
>  response.should redirect_with(:controller => 'admin/users', :action =>
>  'batch_saved')
>
>  This would let you express exactly what you want and only accept a
>  Hash and only match those present in the expectation, ignoring
>  anything else in the Hash.
>
>  I don't have the cycles to add this anytime soon, so if you like the
>  idea, feel free to submit a patch to the tracker.

I'd be happy to do that, although I'm not entirely convinced that
redirect_with is the right name, not that I've got a better
alternative.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/


More information about the rspec-users mailing list