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

Brandon Keepers bkeepers at gmail.com
Mon May 21 23:42:23 EDT 2007

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  

response.should redirect_to(resource_path(@video, @process, @origin))

> Seems like it doesn't like the process_id and origin_id parameters.
> Am I doing anything wrong or is it just a bug with the rails plugin?

My guess is that there is just some little nuance that is wrong.   
Does the url generate right in the browser?


More information about the rspec-users mailing list