require 'rails_helper' module Mks module Edm RSpec.describe EquipmentCategory, type: :model do it 'has a valid factory' do expect(create(:equipment_category)).to be_valid end it 'is invalid with no name' do expect(build(:equipment_category, name: nil)).not_to be_valid end it 'is invalid with no code' do expect(build(:equipment_category, code: nil)).not_to be_valid end it 'is invalid with no type' do expect(build(:equipment_category, equipment_type: nil)).not_to be_valid end it 'is invalid with duplicate code' do ec = create(:equipment_category) expect(build(:equipment_category, code: ec.code)).not_to be_valid end it 'is valid with no description' do expect(create(:equipment_category, description: nil)).to be_valid end end end end