require 'rails_helper' module Mks module Rate RSpec.describe ServiceDeliveryUnit, type: :model do it 'has valid factory' do expect(create(:service_delivery_unit)).to be_valid end it 'is invalid without code' do expect(build(:service_delivery_unit, code: nil)).not_to be_valid end it 'is invalid without name' do expect(build(:service_delivery_unit, name: nil)).not_to be_valid end it 'can not have two service delivery units with same code' do sdu = create(:service_delivery_unit) expect(build(:service_delivery_unit, code: sdu.code)).not_to be_valid end end end end