Browse Source

fixed broken test

pull/78/head
magicmilo 3 years ago
parent
commit
3b0efa5293
  1. 6
      app/helpers/check_answers_helper.rb
  2. 2
      spec/fixtures/forms/test_form.json
  3. 2
      spec/helpers/check_answers_helper_spec.rb

6
app/helpers/check_answers_helper.rb

@ -14,8 +14,10 @@ module CheckAnswersHelper
subsection_keys = form.pages_for_subsection(subsection).keys subsection_keys = form.pages_for_subsection(subsection).keys
page_name = subsection_keys.first page_name = subsection_keys.first
# binding.pry
while page_name.to_s != "check_answers" && subsection_keys.include?(page_name) while page_name.to_s != "check_answers" && subsection_keys.include?(page_name)
binding.pry # binding.pry
questions = form.questions_for_page(page_name) questions = form.questions_for_page(page_name)
applicable_questions = filter_conditional_questions(questions, case_log) applicable_questions = filter_conditional_questions(questions, case_log)
total_questions = total_questions.merge(applicable_questions) total_questions = total_questions.merge(applicable_questions)
@ -53,7 +55,7 @@ module CheckAnswersHelper
end end
def condition_not_met(case_log, question_key, question, condition) def condition_not_met(case_log, question_key, question, condition)
binding.pry # binding.pry
case question["type"] case question["type"]
when "numeric" when "numeric"
operator = condition[/[<>=]+/].to_sym operator = condition[/[<>=]+/].to_sym

2
spec/fixtures/forms/test_form.json vendored

@ -497,7 +497,7 @@
"check_answer_label": "Postcode of previous accomodation if the household has moved from settled accommodation", "check_answer_label": "Postcode of previous accomodation if the household has moved from settled accommodation",
"header": "Postcode for the previous accommodation", "header": "Postcode for the previous accommodation",
"hint_text": "If the household has moved from settled accommodation immediately prior to being re-housed", "hint_text": "If the household has moved from settled accommodation immediately prior to being re-housed",
"type": "text", "type": "date",
"conditional_for": { "faake_key": "fake_condition" } "conditional_for": { "faake_key": "fake_condition" }
} }
} }

2
spec/helpers/check_answers_helper_spec.rb

@ -104,7 +104,7 @@ RSpec.describe CheckAnswersHelper do
end end
it "raises an error" do it "raises an error" do
allow_any_instance_of(Form).to receive(:pages_for_subsection).and_return(unimplemented_conditional) allow_any_instance_of(Form).to receive(:questions_for_page).and_return(unimplemented_conditional)
expect { total_number_of_questions(subsection, case_log, form) }.to raise_error(RuntimeError, "Not implemented yet") expect { total_number_of_questions(subsection, case_log, form) }.to raise_error(RuntimeError, "Not implemented yet")
end end
end end

Loading…
Cancel
Save