|
|
@ -11,7 +11,7 @@ RSpec.describe "form/page" do |
|
|
|
let(:subsection) { form.get_subsection("income_and_benefits") } |
|
|
|
let(:subsection) { form.get_subsection("income_and_benefits") } |
|
|
|
let(:page) { form.get_page("net_income") } |
|
|
|
let(:page) { form.get_page("net_income") } |
|
|
|
let(:question) { page.questions.find { |q| q.id == "earnings" } } |
|
|
|
let(:question) { page.questions.find { |q| q.id == "earnings" } } |
|
|
|
let(:initial_attribs) { { type: "numeric", answer_options: nil } } |
|
|
|
let(:initial_attribs) { { type: "numeric", answer_options: nil, prefix: nil, suffix: nil } } |
|
|
|
|
|
|
|
|
|
|
|
def assign_attributes(object, attrs) |
|
|
|
def assign_attributes(object, attrs) |
|
|
|
attrs.each_pair do |attr, value| |
|
|
|
attrs.each_pair do |attr, value| |
|
|
@ -19,9 +19,6 @@ RSpec.describe "form/page" do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "given a question with extra guidance" do |
|
|
|
|
|
|
|
let(:expected_guidance) { /What counts as income?/ } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
before do |
|
|
|
assign(:case_log, case_log) |
|
|
|
assign(:case_log, case_log) |
|
|
|
assign(:page, page) |
|
|
|
assign(:page, page) |
|
|
@ -36,6 +33,20 @@ RSpec.describe "form/page" do |
|
|
|
assign_attributes(question, initial_attribs) |
|
|
|
assign_attributes(question, initial_attribs) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "given a numeric question with prefix and suffix" do |
|
|
|
|
|
|
|
let(:attribs) { { type: "numeric", prefix: "£", suffix: "every week" } } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "renders prefix and suffix text" do |
|
|
|
|
|
|
|
expect(rendered).to match(/govuk-input__prefix/) |
|
|
|
|
|
|
|
expect(rendered).to match(/£/) |
|
|
|
|
|
|
|
expect(rendered).to match(/govuk-input__suffix/) |
|
|
|
|
|
|
|
expect(rendered).to match("every week") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "given a question with extra guidance" do |
|
|
|
|
|
|
|
let(:expected_guidance) { /What counts as income?/ } |
|
|
|
|
|
|
|
|
|
|
|
context "with radio type" do |
|
|
|
context "with radio type" do |
|
|
|
let(:attribs) { { type: "radio", answer_options: { "1": "A", "2": "B" } } } |
|
|
|
let(:attribs) { { type: "radio", answer_options: { "1": "A", "2": "B" } } } |
|
|
|
it "renders the guidance partial for radio questions" do |
|
|
|
it "renders the guidance partial for radio questions" do |
|
|
|