LoginSignup
0

posted at

updated at

[RSpec]Expected response to be a <3XX: redirect>, but was a <200: OK> - deviseによるログイン / アカウント登録のテスト

RSpec初心者です。
deviseのユーザー認証に関するテストで表題の文言と共にテストに失敗したので、意味を調べました。

Failures:

  1) DeviseSessions POST #sign_in パラメータが正しい場合 ユーザー個別ページにリダイレクトされること
     Failure/Error: expect(response).to redirect_to user_url(user.id)
       Expected response to be a <3XX: redirect>, but was a <200: OK>
...

原因

Createアクション実行後にユーザープロフィールにリダイレクト(status 302)されるところ、Createに失敗してフォームが再表示されている。

The error message means that the create action is failing, and instead of >redirecting to the user's profile (status 302), it renders the form again (status 200)

参考:https://stackoverflow.com/questions/32386685/expected-response-to-be-a-redirect-but-was-200

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
0