require 'rails_helper' module Mks module Edm RSpec.describe Equipment, type: :model do it 'has a valid factory' do expect(create(:equipment)).to be_valid end it 'is invalid with no code' do expect(build(:equipment, code: nil)).not_to be_valid end it 'is invalid with no name' do expect(build(:equipment, name: nil)).not_to be_valid end it 'is invalid with no category' do expect(build(:equipment, equipment_category: nil)).not_to be_valid end it 'is invalid with duplicate code' do eq = create(:equipment) expect(build(:equipment, code: eq.code)).not_to be_valid end it 'is valid with no description' do expect(create(:equipment, description: nil)).to be_valid end it 'sets minimum acquisition time to 0 by default' do eq = create(:equipment, minimum_acquisition_time: nil) expect(eq.minimum_acquisition_time).to eq 0 end end end end