[rspec-users] Using RESTful routes in controller tests

Matthijs Langenberg mlangenberg at gmail.com
Fri Jan 5 09:09:08 EST 2007

Why can't I use the RESTful route helpers in my specs?
In my controller I'm doing a redirect: redirect_to list_path(:id =>
Now when I write: controller.should_redirect_to list_path(:id => 2)
I'm getting the following error:

NoMethodError in 'POST on /lists/2/items should redirect to index on
succesful POST'
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.rewrite
(eval):19:in `list_path'

Finished in 0.114317 seconds

Writing "controller.should_redirect_to :controller => 'lists', :action
=> 'show', :id => 2" works though.

Am I forgetting something?

More information about the rspec-users mailing list