[rspec-users] Using RESTful routes in controller tests

Brandon Keepers bkeepers at gmail.com
Sat Jan 6 10:28:24 EST 2007


There already is one:

https://rubyforge.org/tracker/index.php? 
func=detail&aid=6541&group_id=797&atid=3149

Brandon

On Jan 5, 2007, at 4:15 PM, aslak hellesoy wrote:

> 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
>>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list