Skip to content

Commit

Permalink
Add example groups to relevant specs
Browse files Browse the repository at this point in the history
Refs #68
  • Loading branch information
peteryates committed Nov 16, 2019
1 parent 4bc6fdf commit ecbfc40
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
let(:described_element) { 'fieldset' }
end

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

describe 'check boxes' do
specify 'output should contain the correct number of check boxes' do
expect(subject).to have_tag('div', with: { 'data-module' => 'govuk-checkboxes' }) do |cb|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
let(:error_identifier) { 'person-projects-error' }
end

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

context 'when no block is supplied' do
subject { builder.send(*args) }
specify { expect { subject }.to raise_error(NoMethodError, /undefined method.*call/) }
Expand Down
3 changes: 3 additions & 0 deletions spec/govuk_design_system_formbuilder/builder/date_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
end
end

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

specify 'should output a form group with fieldset, date group and 3 inputs and labels' do
expect(subject).to have_tag('div', with: { class: 'govuk-form-group' }) do |fg|
expect(fg).to have_tag('fieldset', with: { class: 'govuk-fieldset' }) do |fs|
Expand Down
3 changes: 3 additions & 0 deletions spec/govuk_design_system_formbuilder/builder/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
let(:error_identifier) { 'person-photo-error' }
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'

describe 'additional attributes' do
subject { builder.send(method, attribute, accept: 'image/*', multiple: true) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
let(:described_element) { 'fieldset' }
end

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

context 'radio buttons' do
specify 'each radio button should have the correct classes' do
expect(subject).to have_tag('input', with: { class: %w(govuk-radios__input) }, count: colours.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
let(:error_identifier) { 'person-favourite-colour-error' }
end

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

context 'when a block containing radio buttons is supplied' do
specify 'output should be a form group containing a form group and fieldset' do
expect(subject).to have_tag('div', with: { class: 'govuk-form-group' }) do |fg|
Expand Down
3 changes: 3 additions & 0 deletions spec/govuk_design_system_formbuilder/builder/select_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
let(:described_element) { 'select' }
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'

specify 'output should be a form group containing a label and select box' do
expect(subject).to have_tag('div', with: { class: 'govuk-form-group' }) do |fg|
expect(fg).to have_tag('select')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
let(:error_identifier) { 'person-cv-error' }
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'

specify 'should have the correct classes' do
expect(subject).to have_tag('textarea', with: { class: 'govuk-textarea' })
end
Expand Down
11 changes: 10 additions & 1 deletion spec/support/locales/sample.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ helpers:
label:
person:
name: Who goes there?
cv: Tell us about your employment history
favourite_colour: What is your favourite colour?
photo: Upload a recent passport photo
fieldset:
person:
favourite_colour: To which colours are you most partial?
born_on: What is your date of birth?
projects: What do you do all day at work?
hint:
person:
name: Check your birth certificate or passport
name: Enter your full name including middle names, nicknames and aliases
favourite_colour: |-
Yes, there are plenty of options but please pick the one you enjoy most
cv: Where did you work? What did you do?
photo: Make sure your face is clear and you are looking at the camera
born_on: Check your birth certificate or passport
projects: If you cannot remember check with your teammates or manager
3 changes: 3 additions & 0 deletions spec/support/shared/shared_text_field_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
let(:error_identifier) { 'person-name-error' }
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'

context 'extra attributes' do
let(:regular_args) { { label: { text: 'What should we call you?' } } }

Expand Down

0 comments on commit ecbfc40

Please sign in to comment.