diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index cfd1e56a6..f856aa3ba 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -93,49 +93,6 @@ RSpec.describe "Form Features" do ) end - context "Validate pregnancy questions" do - it "Cannot answer yes if no female tenants" do - expect { - CaseLog.create!(preg_occ: "Yes", - sex1: "Male", - age1: 20) - }.to raise_error(ActiveRecord::RecordInvalid) - end - - it "Cannot answer yes if no female tenants within age range" do - expect { - CaseLog.create!(preg_occ: "Yes", - sex1: "Female", - age1: 51) - }.to raise_error(ActiveRecord::RecordInvalid) - end - - it "Cannot answer prefer not to say if no valid tenants" do - expect { - CaseLog.create!(preg_occ: "Prefer not to say", - sex1: "Male", - age1: 20) - }.to raise_error(ActiveRecord::RecordInvalid) - end - - it "Can answer yes if valid tenants" do - expect { - CaseLog.create!(preg_occ: "Yes", - sex1: "Female", - age1: 20) - }.not_to raise_error - end - - it "Can answer yes if valid second tenant" do - expect { - CaseLog.create!(preg_occ: "Yes", - sex1: "Male", age1: 99, - sex2: "Female", - age2: 20) - }.not_to raise_error - end - end - it "can be accessed by url" do visit("/case_logs/#{id}/person_1_age") expect(page).to have_field("case-log-age1-field") diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index ebdcf51df..e19ce4eec 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -96,6 +96,49 @@ RSpec.describe Form, type: :model do end end + context "Validate pregnancy questions" do + it "Cannot answer yes if no female tenants" do + expect { + CaseLog.create!(preg_occ: "Yes", + sex1: "Male", + age1: 20) + }.to raise_error(ActiveRecord::RecordInvalid) + end + + it "Cannot answer yes if no female tenants within age range" do + expect { + CaseLog.create!(preg_occ: "Yes", + sex1: "Female", + age1: 51) + }.to raise_error(ActiveRecord::RecordInvalid) + end + + it "Cannot answer prefer not to say if no valid tenants" do + expect { + CaseLog.create!(preg_occ: "Prefer not to say", + sex1: "Male", + age1: 20) + }.to raise_error(ActiveRecord::RecordInvalid) + end + + it "Can answer yes if valid tenants" do + expect { + CaseLog.create!(preg_occ: "Yes", + sex1: "Female", + age1: 20) + }.not_to raise_error + end + + it "Can answer yes if valid second tenant" do + expect { + CaseLog.create!(preg_occ: "Yes", + sex1: "Male", age1: 99, + sex2: "Female", + age2: 20) + }.not_to raise_error + end + end + context "Shared accomodation bedrooms validation" do it "you must have more than zero bedrooms" do expect {