##環境
Ruby 3.0.2
Rails 6.1.4.1
##状況
バリデーションのテスト実行時に下記のエラー
デフォルトでは大文字と小文字を区別している
model.rb
validates :email, uniqueness: true
spec.rb
it { is_expected.to validate_uniqueness_of(:email) }
Expected Employee to validate that :email is case-sensitively unique,
but this could not be proved.
After taking the given Employee, setting its :email to ‹"dummy
value"›, and saving it as the existing record, then making a new
Employee and setting its :email to a different value, ‹"DUMMY VALUE"›,
the matcher expected the new Employee to be valid, but it was invalid
instead, producing these validation errors:
##解決法
大文字小文字の区別なくテストするignoring_case_sensitivity
メソッドを追加
spec.rb
it { is_expected.to validate_uniqueness_of(:email).ignoring_case_sensitivity }
##参考