Skip to content
This repository has been archived by the owner on Dec 25, 2021. It is now read-only.

Commit

Permalink
user spec reflector
Browse files Browse the repository at this point in the history
  • Loading branch information
chaowudev committed Jul 3, 2019
1 parent fc007c7 commit 30b13df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
8 changes: 0 additions & 8 deletions spec/factories/users.rb

This file was deleted.

10 changes: 5 additions & 5 deletions spec/models/user_spec.rb
Expand Up @@ -2,10 +2,10 @@

RSpec.describe User, type: :model do

let (:user){ User.new(email: 'test@gmail.com', password: 'test2019', gender: true, weight: 55) }

describe 'user\'s information is presence' do
it 'user has email, encrypted_password, gender, weight' do
user = User.create(email: 'test@gmail.com', password: 'test2019', gender: true, weight: 55)

should validate_presence_of(:email)
should validate_presence_of(:encrypted_password)
should validate_presence_of(:gender)
Expand All @@ -24,7 +24,7 @@

it 'email must be unique' do
user = User.create(email: 'test@gmail.com', password: 'test2019', gender: true, weight: 55)
u = User.create(email: 'test@gmail.com', password: 'test2019', gender: true, weight: 55)
u = User.new(email: 'test@gmail.com', password: 'test2019', gender: true, weight: 55)

expect(u).to_not be_valid
expect { raise StandardError, 'email has already been token'}.to raise_error 'email has already been token'
Expand All @@ -33,13 +33,13 @@

describe 'user\'s password format' do
it 'pwd length less than 6 charaters is invalid' do
user = User.create(email: 'test2019@gmail.com', password: '12345', gender: true, weight: 55)
user = User.new(email: 'test2019@gmail.com', password: '12345', gender: true, weight: 55)
expect(user).to_not be_valid
end
end

describe 'user\'s weight' do
it 'user\'s weight must be bigger than 0' do
it 'user\'s weight must be greater than 0' do
should validate_numericality_of(:weight).is_greater_than(0)
end
end
Expand Down

0 comments on commit 30b13df

Please sign in to comment.