Skip to content

Commit

Permalink
Insert the shared examples for nested attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
peteryates committed Apr 12, 2021
1 parent 92ed040 commit 61fd216
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
let(:expected_class) { 'govuk-checkboxes__input' }
end

it_behaves_like 'a field that allows nested HTML attributes to be set' do
let(:described_element) { 'input' }
let(:expected_class) { 'govuk-input' }
end

it_behaves_like 'a field that supports setting the label via localisation'
it_behaves_like 'a field that supports setting the hint via localisation'

Expand Down
5 changes: 5 additions & 0 deletions spec/govuk_design_system_formbuilder/builder/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
let(:expected_class) { 'govuk-file-upload' }
end

it_behaves_like 'a field that allows nested HTML attributes to be set' do
let(:described_element) { 'input' }
let(:expected_class) { 'govuk-input' }
end

it_behaves_like 'a field that accepts a plain ruby object' do
let(:described_element) { ['input', { with: { type: 'file' } }] }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
let(:expected_class) { 'govuk-radios__input' }
end

it_behaves_like 'a field that allows nested HTML attributes to be set' do
let(:described_element) { 'input' }
let(:expected_class) { 'govuk-radios__input' }
end

it_behaves_like 'a field that supports setting the label via localisation'
it_behaves_like 'a field that supports setting the hint via localisation'

Expand Down
19 changes: 8 additions & 11 deletions spec/govuk_design_system_formbuilder/builder/select_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

let(:field_type) { 'select' }
let(:aria_described_by_target) { 'select' }
let(:described_element) { 'select' }
let(:expected_class) { 'govuk-select' }

describe '#govuk_collection_select' do
let(:attribute) { :favourite_colour }
Expand All @@ -29,14 +31,9 @@
let(:error_class) { 'govuk-select--error' }
end

it_behaves_like 'a field that accepts arbitrary blocks of HTML' do
let(:described_element) { 'select' }
end

it_behaves_like 'a field that allows extra HTML attributes to be set' do
let(:described_element) { 'select' }
let(:expected_class) { 'govuk-select' }
end
it_behaves_like 'a field that accepts arbitrary blocks of HTML'
it_behaves_like 'a field that allows extra HTML attributes to be set'
it_behaves_like 'a field that allows nested HTML attributes to be set'

it_behaves_like 'a field that supports setting the label via localisation'
it_behaves_like 'a field that supports setting the label caption via localisation'
Expand Down Expand Up @@ -116,9 +113,9 @@
it_behaves_like 'a field that supports setting the label caption via localisation'
it_behaves_like 'a field that supports setting the hint via localisation'

it_behaves_like 'a field that accepts a plain ruby object' do
let(:described_element) { 'select' }
end
it_behaves_like 'a field that accepts a plain ruby object'
it_behaves_like 'a field that allows extra HTML attributes to be set'
it_behaves_like 'a field that allows nested HTML attributes to be set'

specify 'a select element is rendered' do
expect(subject).to have_tag('div', with: { class: 'govuk-form-group' }) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
let(:expected_class) { 'govuk-textarea' }
end

it_behaves_like 'a field that allows nested HTML attributes to be set' do
let(:described_element) { 'textarea' }
let(:expected_class) { 'govuk-textarea' }
end

it_behaves_like 'a field that accepts a plain ruby object' do
let(:described_element) { 'textarea' }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared/shared_html_attribute_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
end
end

shared_examples 'a field that allow nested HTML attributes to be set' do
shared_examples 'a field that allows nested HTML attributes to be set' do
let(:example_block) { proc { builder.tag.span('block text') } }

context 'when aria-describedby is provided as a string' do
Expand Down
5 changes: 5 additions & 0 deletions spec/support/shared/shared_text_field_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
let(:expected_class) { 'govuk-input' }
end

it_behaves_like 'a field that allows nested HTML attributes to be set' do
let(:described_element) { 'input' }
let(:expected_class) { 'govuk-input' }
end

describe 'width' do
context 'custom widths' do
{
Expand Down

0 comments on commit 61fd216

Please sign in to comment.