[rspec-users] Using RESTful routes in controller tests

aslak hellesoy aslak.hellesoy at gmail.com
Fri Jan 5 16:15:38 EST 2007


Sounds like a bug/missing feature. Please submit a feature request at
Rubyforge, with a failing spec if you can.

On 1/5/07, Matthijs Langenberg <mlangenberg at gmail.com> wrote:
> 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 =>
> @item.list_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'
> ./spec/controllers/items_controller_spec.rb:36:
>
> Finished in 0.114317 seconds
>
> Writing "controller.should_redirect_to :controller => 'lists', :action
> => 'show', :id => 2" works though.
>
> Am I forgetting something?
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list