diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 1c77b47d6..e09c209e8 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -668,7 +668,7 @@ RSpec.describe Form, type: :model do it "updates soft errors" do expect(case_log.has_no_unresolved_soft_errors?).to be false expect(case_log.soft_errors["override_net_income_validation"].message) - .to match(/Net income is higher than expected/) + .to match(I18n.t("soft_validations.net_income.in_soft_max_range.message")) end end @@ -683,7 +683,7 @@ RSpec.describe Form, type: :model do it "updates soft errors" do expect(case_log.has_no_unresolved_soft_errors?).to be false expect(case_log.soft_errors["override_net_income_validation"].message) - .to match(/Net income is lower than expected/) + .to match(I18n.t("soft_validations.net_income.in_soft_min_range.message")) end end end @@ -1090,12 +1090,12 @@ RSpec.describe Form, type: :model do it "errors if the property postcode is emptied" do expect { address_case_log.update!({ property_postcode: "" }) } - .to raise_error(ActiveRecord::RecordInvalid, /Enter a postcode in the correct format/) + .to raise_error(ActiveRecord::RecordInvalid, /#{I18n.t("validations.postcode")}/) end it "errors if the property postcode is not valid" do expect { address_case_log.update!({ property_postcode: "invalid_postcode" }) } - .to raise_error(ActiveRecord::RecordInvalid, /Enter a postcode in the correct format/) + .to raise_error(ActiveRecord::RecordInvalid, /#{I18n.t("validations.postcode")}/) end it "correctly resets all fields if property postcode not known" do diff --git a/spec/models/validations/local_authority_validations_spec.rb b/spec/models/validations/local_authority_validations_spec.rb index c62607e2a..d6e6d0328 100644 --- a/spec/models/validations/local_authority_validations_spec.rb +++ b/spec/models/validations/local_authority_validations_spec.rb @@ -17,7 +17,7 @@ RSpec.describe CaseLog do owning_organisation: owning_organisation, managing_organisation: managing_organisation, ) - }.to raise_error(ActiveRecord::RecordInvalid, /Enter a postcode in the correct format/) + }.to raise_error(ActiveRecord::RecordInvalid, /#{I18n.t("validations.postcode")}/) end end end @@ -50,7 +50,7 @@ RSpec.describe Validations::LocalAuthorityValidations do record.previous_postcode = "invalid" subject.validate_previous_accommodation_postcode(record) expect(record.errors).to_not be_empty - expect(record.errors["previous_postcode"]).to include(match /Enter a postcode in the correct format/) + expect(record.errors["previous_postcode"]).to include(match I18n.t("validations.postcode")) end end end