Hello, I wanted to ask if someone could explain something to me. I have a Category model with only name:string created using resource_controller. I have no problem creating new, editing and/or deleting. When I create new or edit/update, I am redirected to the new/ edited record. So, everything is as usual. I have 2 tests for: test_should_create_category and test_should_update_category that include: assert_redirected_to category_path(assigns(:category)) But when running the test I get: Expected response to be a <:redirect>, but was <200> The thing I don''t understand is that I do get redirected -- so why is the test failing? Thanks, Elle --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Apr-04 10:33 UTC
Re: Test: Expected response to be a <:redirect>, but was <200>
On Apr 4, 4:42 am, elle <wazne...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have 2 tests for: test_should_create_category and > test_should_update_category that include: > assert_redirected_to category_path(assigns(:category)) > But when running the test I get: > Expected response to be a <:redirect>, but was <200> > > The thing I don''t understand is that I do get redirected -- so why is > the test failing? >Well for the real answer step through your code in the debugger, but I''d guess its something like a failing validation because your test isn''t posting the right parameters. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Installed debugger and re-looked at my tests. I didn''t assign values for new category and for update category => therefore, the tests failed. All good now. Thanks Fred once again :) Elle On Apr 4, 8:33 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Apr 4, 4:42 am, elle <wazne...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have 2 tests for: test_should_create_category and > > test_should_update_category that include: > > assert_redirected_to category_path(assigns(:category)) > > But when running the test I get: > > Expected response to be a <:redirect>, but was <200> > > > The thing I don''t understand is that I do get redirected -- so why is > > the test failing? > > Well for the real answer step through your code in the debugger, but > I''d guess its something like a failing validation because your test > isn''t posting the right parameters. > > Fred--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---