2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

単体テストコードのエラーの見方

Posted at

はじめに#

テストコードのコマンドを入力すると赤文字でめっちゃ出てきた!
https://gyazo.com/7ad592a7615a81daf0aef6e599062de3

見方#

まず見方については

 expected #<User id: nil, email: "quinn.olson@hotmail.com", nickname: "FA", 
first_name: "佐藤", last_name: "太郎", first_name_kana: "テスト", last_name_kana: "テスト"
, birthday: "2020-05-21", created_at: nil, updated_at: nil> to be valid

ここはエラーではなく最後に to be valid となっているのでここまではテストに成功しているという意味です。
ここからがエラーです。

but got errors: Password には英字と数字の両方を含めて設定してください

なので FactoryBot の password を

password {Faker::Internet.password(min_length: 6)}
password_confirmation {password}

から

password              {'abc123'}
password_confirmation {'abc123'}

に変更するだけでエラーが解消されました!

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?