Simplify stubbing age responses in residence tests
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user