LoginSignup
0
0

More than 1 year has passed since last update.

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

Last updated at Posted at 2022-04-28

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

0
0
0

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
  3. You can use dark theme
What you can do with signing up
0
0