diff --git a/spec/models/validations/sales/household_validations_spec.rb b/spec/models/validations/sales/household_validations_spec.rb index ea581c096..b7ea4f663 100644 --- a/spec/models/validations/sales/household_validations_spec.rb +++ b/spec/models/validations/sales/household_validations_spec.rb @@ -7,42 +7,42 @@ RSpec.describe Validations::Sales::HouseholdValidations do describe "#validate_number_of_other_people_living_in_the_property" do context "when within permitted bounds" do - let(:record) { FactoryBot.build(:sales_log, hholdcount: 2) } + let(:record) { build(:sales_log, hholdcount: 2) } it "does not add an error" do household_validator.validate_number_of_other_people_living_in_the_property(record) - expect(record.errors).not_to be_present + expect(record.errors[:hholdcount]).not_to be_present end end context "when blank" do - let(:record) { FactoryBot.build(:sales_log, hholdcount: nil) } + let(:record) { build(:sales_log, hholdcount: nil) } it "does not add an error" do household_validator.validate_number_of_other_people_living_in_the_property(record) - expect(record.errors).not_to be_present + expect(record.errors[:hholdcount]).not_to be_present end end context "when below lower bound" do - let(:record) { FactoryBot.build(:sales_log, hholdcount: -1) } + let(:record) { build(:sales_log, hholdcount: -1) } it "adds an error" do household_validator.validate_number_of_other_people_living_in_the_property(record) - expect(record.errors).to be_present + expect(record.errors[:hholdcount]).to be_present end end context "when higher than upper bound" do - let(:record) { FactoryBot.build(:sales_log, hholdcount: 5) } + let(:record) { build(:sales_log, hholdcount: 5) } it "adds an error" do household_validator.validate_number_of_other_people_living_in_the_property(record) - expect(record.errors).to be_present + expect(record.errors[:hholdcount]).to be_present end end end