Skip to content

Commit

Permalink
Create user_spec.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Sep 20, 2024
1 parent 7fa9c6e commit 9e3389a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions global_business/business/spec/models/user_spec.rb
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

0 comments on commit 9e3389a

Please sign in to comment.