From df592aa6a3f676d551b119daa214656bfcbafa16 Mon Sep 17 00:00:00 2001 From: Matthew Phelan Date: Tue, 12 Oct 2021 12:09:26 +0100 Subject: [PATCH] tenant_age validation tests --- spec/features/case_log_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index b83ccb932..2b13121ff 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -291,4 +291,24 @@ RSpec.describe "Test Features" do end end end + + describe "Question validation" do + context "given an invalid tenant age" do + it " of less than 0 it shows validation" do + visit("/case_logs/#{id}/tenant_age") + fill_in_number_question(empty_case_log.id, "tenant_age", -5) + expect(page).to have_selector("#error-summary-title") + expect(page).to have_selector("#case-log-tenant-age-error") + expect(page).to have_selector("#case-log-tenant-age-field-error") + end + + it " of greater than 100 it shows validation" do + visit("/case_logs/#{id}/tenant_age") + fill_in_number_question(empty_case_log.id, "tenant_age", 120) + expect(page).to have_selector("#error-summary-title") + expect(page).to have_selector("#case-log-tenant-age-error") + expect(page).to have_selector("#case-log-tenant-age-field-error") + end + end + end end