From d85e0da0783ec286f3be2f762728d534c987d83b Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Mon, 13 Sep 2021 14:56:51 +0100 Subject: [PATCH] Don't need to create our own question markup --- app/views/form/age.html.erb | 5 --- app/views/form/index.html.erb | 23 +++++--------- .../questions/_numeric_question.html.erb | 7 ----- spec/features/form_spec.rb | 2 +- .../_numeric_question.html.erb_spec.rb | 31 ------------------- 5 files changed, 8 insertions(+), 60 deletions(-) delete mode 100644 app/views/form/age.html.erb delete mode 100644 app/views/questions/_numeric_question.html.erb delete mode 100644 spec/views/questions/_numeric_question.html.erb_spec.rb diff --git a/app/views/form/age.html.erb b/app/views/form/age.html.erb deleted file mode 100644 index 6836f7080..000000000 --- a/app/views/form/age.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%= turbo_frame_tag "form" %> - <%= form_with url:'/test', builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> - <%= f.govuk_number_field :age, label: { text: "Test" } %> - <%= f.govuk_submit %> - <% end %> \ No newline at end of file diff --git a/app/views/form/index.html.erb b/app/views/form/index.html.erb index 27eb369a1..7889ea55a 100644 --- a/app/views/form/index.html.erb +++ b/app/views/form/index.html.erb @@ -1,17 +1,8 @@ -<%= form_with url:'/test', builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> - <%= f.govuk_number_field :age, label: { text: "Age" } %> +<%= form_with builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> + <%= f.govuk_number_field :age, + hint: { text: "More detail" }, + label: { text: "What is the tenant's age?", size: "l"}, + min: 0, max: 150, step: 1, width: 20 + %> <%= f.govuk_submit %> - <% end %> - - <%= link_to "/age", class: "govuk-header__link govuk-header__link--homepage" do %> - - - - - - - GOV.UK - - - <% end %> - +<% end %> diff --git a/app/views/questions/_numeric_question.html.erb b/app/views/questions/_numeric_question.html.erb deleted file mode 100644 index 1188a87c4..000000000 --- a/app/views/questions/_numeric_question.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -
- -
- <%= hint_text %> -
- max=<%= maximum %> /> -
\ No newline at end of file diff --git a/spec/features/form_spec.rb b/spec/features/form_spec.rb index 7fb2779c2..87668de5f 100644 --- a/spec/features/form_spec.rb +++ b/spec/features/form_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" RSpec.describe "Test Features" do it "Displays the name of the app" do visit("/form") - expect(page).to have_field("Age") + expect(page).to have_field("age") expect(page).to have_button("Continue") end end diff --git a/spec/views/questions/_numeric_question.html.erb_spec.rb b/spec/views/questions/_numeric_question.html.erb_spec.rb deleted file mode 100644 index 8949790f7..000000000 --- a/spec/views/questions/_numeric_question.html.erb_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -describe "questions/_numeric_question.html.erb" do - context "when given a label, value constraints and hint text" do - let(:label) { "Test Label" } - let(:min) { "1" } - let(:max) { "150" } - let(:hint_text) { "Some text that describes the question in more detail" } - let(:locals) { { label: label, minimum: min, maximum: max, hint_text: hint_text } } - - before(:each) do - render partial: "numeric_question", locals: locals - end - - it "displays a numeric entry field with a label" do - expect(rendered).to have_selector('//input[@type="number"]') - expect(rendered).to have_selector("//label[contains('#{label}')]") - end - - it "validates for a given minimum input" do - expect(rendered).to have_selector("//input[@min=#{min}]") - end - - it "validates for a given maximum input" do - expect(rendered).to have_selector("//input[@max=#{max}]") - end - - it "displays hint text" do - expect(rendered).to have_selector("//div[@class='govuk-hint']") - expect(rendered).to have_css("#numeric_hint", text: hint_text.to_s) - end - end -end