require 'rails_helper' module Mks module Rate RSpec.describe UnitOfCharge, type: :model do it 'has valid factory' do expect(build(:unit_of_charge)).to be_valid end it 'is invalid without name' do expect(build(:unit_of_charge, name: nil)).not_to be_valid end it 'is invalid without unit variables' do expect(build(:unit_of_charge, unit_variables: {})).not_to be_valid end it 'can not have same name' do uoc = create(:unit_of_charge) expect(build(:unit_of_charge, name: uoc.name)).not_to be_valid end end end end