Browse Source

Move model specs to model

pull/111/head
baarkerlounger 3 years ago
parent
commit
b994e6ca0c
  1. 43
      spec/features/case_log_spec.rb
  2. 43
      spec/models/case_log_spec.rb

43
spec/features/case_log_spec.rb

@ -93,49 +93,6 @@ RSpec.describe "Form Features" 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
it "can be accessed by url" do it "can be accessed by url" do
visit("/case_logs/#{id}/person_1_age") visit("/case_logs/#{id}/person_1_age")
expect(page).to have_field("case-log-age1-field") expect(page).to have_field("case-log-age1-field")

43
spec/models/case_log_spec.rb

@ -96,6 +96,49 @@ RSpec.describe Form, type: :model do
end end
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 context "Shared accomodation bedrooms validation" do
it "you must have more than zero bedrooms" do it "you must have more than zero bedrooms" do
expect { expect {

Loading…
Cancel
Save