diff --git a/spec/models/officing/residence_spec.rb b/spec/models/officing/residence_spec.rb index 96df02b1d..a9d842d85 100644 --- a/spec/models/officing/residence_spec.rb +++ b/spec/models/officing/residence_spec.rb @@ -130,13 +130,15 @@ describe Officing::Residence do describe "allowed age" do it "is not valid if user is under allowed age" do - allow_any_instance_of(Officing::Residence).to receive(:response_date_of_birth).and_return(15.years.ago) + allow(residence).to receive(:response_date_of_birth).and_return(15.years.ago) + expect(residence).not_to be_valid expect(residence.errors[:year_of_birth]).to include("You don't have the required age to participate") end it "is valid if user is above allowed age" do - allow_any_instance_of(Officing::Residence).to receive(:response_date_of_birth).and_return(16.years.ago) + allow(residence).to receive(:response_date_of_birth).and_return(16.years.ago) + expect(residence).to be_valid expect(residence.errors[:year_of_birth]).to be_empty end