-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe User, type: :model do | ||
it { is_expected.to validate_presence_of(:email) } | ||
it { is_expected.to validate_uniqueness_of(:email) } | ||
it { is_expected.to have_secure_password } | ||
it { is_expected.to have_many(:accounts) } | ||
|
||
describe 'password validation' do | ||
it 'validates password length' do | ||
user = User.new(password: 'short') | ||
expect(user).not_to be_valid | ||
end | ||
|
||
it 'validates password complexity' do | ||
user = User.new(password: 'password123') | ||
expect(user).not_to be_valid | ||
end | ||
end | ||
|
||
describe 'email validation' do | ||
it 'validates email format' do | ||
user = User.new(email: 'invalid_email') | ||
expect(user).not_to be_valid | ||
end | ||
end | ||
end |