Skip to content

Commit

Permalink
Make error summary specs a little more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
peteryates committed Mar 20, 2021
1 parent 838ab8a commit 5d5dfb0
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions spec/govuk_design_system_formbuilder/builder/error_summary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,15 @@
end

specify 'the radio button linked to should be first' do
expect(parsed_subject.css('input[type="radio"]').first['id']).to eql(identifier)
expect(parsed_subject.css('label').first['for']).to eql(identifier)
first_radio = parsed_subject.css('input').find { |e| e['type'] == 'radio' }

expect(first_radio['id']).to eql(identifier)
end

specify 'there should be a label associated with the error link target' do
expect(subject).to have_tag('label', with: { for: identifier }, count: 1)
first_label = parsed_subject.css('label').first

expect(first_label['for']).to eql(identifier)
end
end

Expand Down Expand Up @@ -162,12 +165,15 @@
end

specify 'the radio button linked to should be first' do
expect(parsed_subject.css('input').first['id']).to eql(identifier)
expect(parsed_subject.css('label').first['for']).to eql(identifier)
first_radio = parsed_subject.css('input').find { |e| e['type'] == 'radio' }

expect(first_radio['id']).to eql(identifier)
end

specify 'there should be a label associated with the error link target' do
expect(subject).to have_tag('label', with: { for: identifier }, count: 1)
first_label = parsed_subject.css('label').first

expect(first_label['for']).to eql(identifier)
end

specify 'the second radio button should have a regular id' do
Expand Down Expand Up @@ -195,12 +201,15 @@
end

specify 'the check box linked to should be first' do
expect(parsed_subject.css("input[type='checkbox']").first['id']).to eql(identifier)
expect(parsed_subject.css('label').first['for']).to eql(identifier)
first_checkbox = parsed_subject.css('input').find { |e| e['type'] == 'checkbox' }

expect(first_checkbox['id']).to eql(identifier)
end

specify 'there should be a label associated with the error link target' do
expect(subject).to have_tag('label', with: { for: identifier }, count: 1)
first_label = parsed_subject.css('label').first

expect(first_label['for']).to eql(identifier)
end
end

Expand Down Expand Up @@ -231,13 +240,16 @@
expect(subject).to have_tag('input', with: { type: 'checkbox', id: identifier }, count: 1)
end

specify 'the radio button linked to should be first' do
expect(parsed_subject.css(%(input[type='checkbox'])).first['id']).to eql(identifier)
expect(parsed_subject.css('label').first['for']).to eql(identifier)
specify 'the checkbox button linked to should be first' do
first_checkbox = parsed_subject.css('input').find { |e| e['type'] == 'checkbox' }

expect(first_checkbox['id']).to eql(identifier)
end

specify 'there should be a label associated with the error link target' do
expect(subject).to have_tag('label', with: { for: identifier }, count: 1)
first_label = parsed_subject.css('label').first

expect(first_label['for']).to eql(identifier)
end

specify 'the second radio button should have a regular id' do
Expand Down

0 comments on commit 5d5dfb0

Please sign in to comment.