Forum: Ruby on Rails Test: Expected response to be a <:redirect>, but was <200>

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fc6f5b908cfa12868292f985e0de2788?d=identicon&s=25 elle (Guest)
on 2009-04-04 05:43
(Received via mailing list)
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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-04 12:34
(Received via mailing list)
On Apr 4, 4:42 am, elle <wazne...@gmail.com> 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
Fc6f5b908cfa12868292f985e0de2788?d=identicon&s=25 elle (Guest)
on 2009-04-06 02:16
(Received via mailing list)
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...@gmail.com>
This topic is locked and can not be replied to.