It's completely for me. I will leave the quirky code for unit testing (user registration) of the model.
user_spec.rb
it 'mail address is,@Must include' do
@user.email.delete!('@')
@user.valid?
expect(@user.errors.full_messages).to include("Email address is incorrect")
end
user_spec.rb
it 'The password must be entered with at least 6 characters' do
@user.password = '12345'
@user.password_confirmation = @user.password
@user.valid?
expect(@user.errors.full_messages).to include("Please enter the password with at least 6 characters")
end
user_spec.rb
it 'The password must be entered without half-width alphabetic characters.' do
@user.password = '123456'
@user.password_confirmation = @user.password
@user.valid?
expect(@user.errors.full_messages).to include("Password is an invalid value")
end
user_spec.rb
it 'The password must be entered without half-width numbers.' do
@user.password = 'abcdef'
@user.password_confirmation = @user.password
@user.valid?
expect(@user.errors.full_messages).to include("Password is an invalid value")
end
user_spec.rb
it 'Password cannot be registered with double-byte numbers' do
@user.password = '12345a'
@user.password_confirmation = @user.password
@user.valid?
expect(@user.errors.full_messages).to include("Password is an invalid value")
end
user_spec.rb
it 'Password and password (Kakunin), value matching is required' do
@user.password = '12345a'
@user.password_confirmation = '12345b'
@user.valid?
expect(@user.errors.full_messages).to include("The password (Kakunin) and password input do not match")
end
Recommended Posts