[rspec-users] Spec'ing redirect with arbitrary parameters

Pat Maddox pergesu at gmail.com
Tue May 22 13:55:28 EDT 2007


On 5/21/07, Brandon Keepers <bkeepers at gmail.com> wrote:
>
> On May 21, 2007, at 5:09 PM, Pat Maddox wrote:
>
> > I've got the following expectation:
> >
> > response.should redirect_to(:action => "new", :video_id => "1",
> > :process_id => "2", :origin_id => "3")
>
> > that fails with this error message:
> >
> > expected redirect to {:video_id=>"1", :process_id=>"2",
> > :origin_id=>"3", :action=>"new"}, got redirect to
> > "http://test.host/videos/1/screenshot_selections/new?
> > process_id=2&origin_id=3",
> > which cannot be routed within this application (spec using the URL
> > string if the redirection is to an external address)
>
> You may need the controller name in the params.
>
> It looks like you're using resources.  If that's the case, use named
> routes:
>
> response.should redirect_to(resource_path(@video, @process, @origin))

Cool, I changed it to
response.should redirect_to(new_screenshot_selection_path(:video_id =>
"1", :process_id => "2", :origin_id => "3"))

and it works fine now.  Thanks for the tip.

Pat


More information about the rspec-users mailing list