Skip to content

Expected response to be a <:redirect>, but was <0>

If you’re seeing this in your test:

Expected response to be a <:redirect> , but was <0>

You are probably doing something like this in your controller:

redirect_to :action => 'messages', :status => 'read'

Watch out when using :status in your params. :status is used to set the http status code in the redirect_to method, like so:

redirect_to :action=>'atom', :status=>302

Posted in Rails, Ruby, Software Development, Tips and Tricks.

Tagged with , , , .

One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Doug says

    My error was much simpler than this. My editor does auto completion. I typed “p”, hit ESCAPE (for the autocompletion), and got “puts” instead of “put”. So where I wanted:

    put :update, :id => some_id, :some_object => { }

    I had in my code:

    puts :update, :id => some_id, :some_object => { }

    “puts” of course returns no redirect.

Some HTML is OK

or, reply to this post via trackback.