From b994e6ca0ca3672e182700d007a01a41579b64b4 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Wed, 24 Nov 2021 18:54:09 +0000 Subject: [PATCH] Move model specs to model --- spec/features/case_log_spec.rb | 43 ---------------------------------- spec/models/case_log_spec.rb | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 43 deletions(-) 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 {