33 lines
809 B
Ruby
33 lines
809 B
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Project, type: :model do
|
|
|
|
it 'has a valid factory' do
|
|
expect(build(:project)).to be_valid
|
|
end
|
|
|
|
describe 'users test' do
|
|
it 'has at least on user' do
|
|
project_with_no_user = build(:project)
|
|
project_with_no_user.users = []
|
|
project_with_no_user.valid?
|
|
expect(project_with_no_user.errors[:users].size).to eq(1)
|
|
end
|
|
end
|
|
|
|
describe 'name test' do
|
|
it 'does not allow absence of name' do
|
|
expect(build(:project, name: nil)).to_not be_valid
|
|
end
|
|
|
|
it 'length of name in [1,20]' do
|
|
expect(build(:project_name_length_gt_20)).to_not be_valid
|
|
end
|
|
|
|
it 'does not allow duplicate name' do
|
|
create(:project, name: 'project1')
|
|
expect(build(:project, name: 'project1')).to_not be_valid
|
|
end
|
|
end
|
|
end
|