source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/setup_builder.rb
Ruby
mit
92
main
556
shared_context 'setup builder' do let(:assigns) { {} } let(:controller) { ActionController::Base.new } let(:lookup_context) { ActionView::LookupContext.new(nil) } let(:helper) { ActionView::Base.new(lookup_context, assigns, controller) } let(:object) { Person.new(name: 'Joey') } let(:object_name) { :person ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/shared_error_examples.rb
Ruby
mit
92
main
2,692
shared_examples 'a field that supports errors' do context 'when the attribute has errors' do before { object.valid? } specify 'an error message should be displayed' do expect(subject).to have_tag('p', with: { class: 'govuk-error-message' }, text: error_message) end specify %(error has a hidden...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/shared_value_examples.rb
Ruby
mit
92
main
1,601
shared_examples 'a collection field that supports setting the value via a proc with symbols' do let(:args) { [method, attribute, stationery, ->(item) { item }, ->(item) { item.capitalize }] } context 'when the values are symbols' do specify 'the values should be present' do stationery.each { |item| expec...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/shared_custom_class_examples.rb
Ruby
mit
92
main
824
shared_examples 'a field that supports custom classes' do let(:block_content) { -> { %(You there, fill it up with petroleum distillate, and re-vulcanize my tires, post-haste!) } } subject { builder.send(*args, class: custom_classes, &block_content) } context 'when classes are supplied in an array' do let(:cu...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/shared_legend_examples.rb
Ruby
mit
92
main
5,541
shared_examples 'a field that supports a fieldset with legend' do context 'when a legend is supplied' do context 'when text is supplied' do subject { builder.send(*args, legend: { text: legend_text }) } specify 'legend tag should be present' do expect(subject).to have_tag('legend') end ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/shared_form_group_examples.rb
Ruby
mit
92
main
1,311
shared_examples 'a field that contains a customisable form group' do let(:block_content) { %(Are you acquainted with our state's stringent usury laws?) } example_group 'when custom classes are provided' do let(:default_class) { %w(govuk-form-group) } subject do builder.send(*args, form_group: { clas...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/shared_fieldset_item_examples.rb
Ruby
mit
92
main
2,132
shared_examples 'a fieldset item that can conditionally-reveal content' do context 'when a block is given' do specify 'should place the conditional content at the same level as the container' do expect(parsed_subject).to have_root_element_with_class("govuk-#{fieldset_item_type}__conditional") end s...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/localisation_examples/setting_the_label_via_localisation_examples.rb
Ruby
mit
92
main
2,464
shared_examples 'a field that supports setting the label via localisation' do let(:localisations) { { en: YAML.load_file('spec/support/locales/sample.en.yaml') } } context 'localising when no text is supplied' do let(:localisation_key) do defined?(value) ? "#{attribute}_options.#{value}" : attribute ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/localisation_examples/setting_fieldset_hints_via_localisation_examples.rb
Ruby
mit
92
main
603
shared_examples 'a field that supports localised fieldset hints' do let(:localisations) { { en: YAML.load_file('spec/support/locales/collection_hints.en.yaml').deep_symbolize_keys } } let(:expected_hints) { localisations.dig(:en, :helpers, :hint, :person, localisation_key) } specify 'the hints should be set by l...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/localisation_examples/setting_the_hint_via_localisation_examples.rb
Ruby
mit
92
main
2,248
shared_examples 'a field that supports setting the hint via localisation' do let(:localisations) { { en: YAML.load_file('spec/support/locales/sample.en.yaml') } } context 'localising when no text is supplied' do let(:expected_hint) do if defined?(value) && value.present? I18n.translate("helpers.h...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/localisation_examples/setting_collection_hints_via_localisation_examples.rb
Ruby
mit
92
main
1,225
shared_examples 'a field that supports localised collection hints' do let(:localisations) { { en: YAML.load_file('spec/support/locales/sample.en.yaml') } } let(:attribute) { :department } subject { builder.send(*args) } specify 'the hints should be set by localisation' do with_localisations(localisations) ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/localisation_examples/setting_collection_labels_via_localisation_examples.rb
Ruby
mit
92
main
566
shared_examples 'a field that supports localised collection labels' do let(:localisations) { { en: YAML.load_file('spec/support/locales/sample.en.yaml') } } let(:attribute) { :department } subject { builder.send(*args) } specify 'the labels should be set by localisation' do with_localisations(localisations...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/localisation_examples/setting_the_label_via_localisation_with_a_proc_examples.rb
Ruby
mit
92
main
655
shared_examples 'a field that allows the label to be localised via a proc' do let(:locale) { :de } let(:localisations) { YAML.load_file('spec/support/locales/colours.de.yaml') } context 'localising collection items using procs' do subject { builder.send(*args) } specify 'labels should be present and cor...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/localisation_examples/setting_the_label_caption_via_localisation_examples.rb
Ruby
mit
92
main
2,182
shared_examples 'a field that supports setting the label caption via localisation' do let(:localisations) { { en: YAML.load_file('spec/support/locales/sample.en.yaml') } } context 'localising when no text is supplied' do let(:localisation_key) { attribute } let(:expected_caption) do I18n.translate(l...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/localisation_examples/setting_the_legend_caption_via_localisation_examples.rb
Ruby
mit
92
main
2,050
shared_examples 'a field that supports setting the legend caption via localisation' do let(:localisations) { { en: YAML.load_file('spec/support/locales/sample.en.yaml') } } context 'localising when no text is supplied' do let(:localisation_key) { attribute } let(:expected_caption) do I18n.translate(...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/localisation_examples/setting_the_legend_via_localisation_examples.rb
Ruby
mit
92
main
2,395
shared_examples 'a field that supports setting the legend via localisation' do let(:localisations) { { en: YAML.load_file('spec/support/locales/sample.en.yaml') } } context 'localising when no text is supplied' do let(:expected_legend) { I18n.translate("helpers.legend.person.#{attribute}") } subject { buil...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/support/shared/localisation_examples/setting_the_hint_via_localisation_with_a_proc_examples.rb
Ruby
mit
92
main
650
shared_examples 'a field that allows the hint to be localised via a proc' do let(:locale) { :de } let(:localisations) { YAML.load_file('spec/support/locales/colours.de.yaml') } context 'localising collection items using procs' do subject { builder.send(*args) } specify 'hints should be present and corre...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/helper/builder_helper_spec.rb
Ruby
mit
92
main
4,168
class Dummy include GOVUKDesignSystemFormBuilder::BuilderHelper include ActionView::Helpers::TagHelper include ActionView::Helpers::UrlHelper attr_accessor :output_buffer def initialize @output_buffer = ActionView::OutputBuffer.new end end describe GOVUKDesignSystemFormBuilder::BuilderHelper, type: :...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/traits/localisation/schema_path_spec.rb
Ruby
mit
92
main
1,566
def justify(pad, arr) arr.to_s.ljust(pad, ' ') end describe GOVUKDesignSystemFormBuilder::Traits::Localisation do let(:base_name_regexp) { GOVUKDesignSystemFormBuilder::Traits::Localisation::BASE_NAME_REGEXP } describe "BASE_NAME_REGEXP" do examples = { "attribute[a][b][c]" ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/text_area_spec.rb
Ruby
mit
92
main
6,995
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' let(:method) { :govuk_text_area } let(:attribute) { :cv } let(:label_text) { 'A brief list of your achievements' } let(:hint_text) { 'Keep it to a page, nobody will read it anyway' } let(:args) { [method, attribute] } l...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/fieldset_spec.rb
Ruby
mit
92
main
4,233
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' describe '#govuk_fieldset' do let(:method) { :govuk_fieldset } let(:legend_text) { 'Current address' } let(:inner_text) { 'Where do you live?' } let(:legend_options) { { text: legend_text } } let(:example_bl...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/error_summary_spec.rb
Ruby
mit
92
main
21,850
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' let(:method) { :govuk_error_summary } describe '#govuk_error_summary' do let(:args) { [method] } subject { builder.send(*args) } context 'when the object has errors' do bef...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/label_spec.rb
Ruby
mit
92
main
2,448
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' describe '#govuk_password_field' do let(:custom_label_text) { "What's your name?" } let(:method) { :govuk_label } let(:attribute) { :name } let(:args) { [method, attribute] } let(:kwargs) { { text: custom_labe...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/password_spec.rb
Ruby
mit
92
main
10,004
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' describe '#govuk_password_field' do let(:method) { :govuk_password_field } let(:attribute) { :password } let(:label_text) { 'Enter your password' } let(:hint_text) { 'Keep it safe' } let(:args) { [method, attr...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/time_spec.rb
Ruby
mit
92
main
13,013
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' describe '#govuk_time_field' do let(:method) { :govuk_time_field } let(:attribute) { :born_at } let(:fieldset_heading) { 'Time of birth' } let(:legend_text) { 'When were you born?' } let(:hint_text) { 'It say...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/file_spec.rb
Ruby
mit
92
main
7,307
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' describe '#govuk_file_field' do let(:method) { :govuk_file_field } let(:attribute) { :photo } let(:label_text) { 'Upload an image' } let(:hint_text) { 'Only JPEGs are accepted' } let(:args) { [method, attribu...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/submit_spec.rb
Ruby
mit
92
main
6,460
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' describe '#submit' do let(:method) { :govuk_submit } let(:text) { 'Create' } let(:args) { [method] } subject { builder.send(method, text) } include_examples 'HTML formatting checks' it_behaves_like 'a fi...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/select_spec.rb
Ruby
mit
92
main
8,432
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' let(:field_type) { 'select' } let(:aria_described_by_target) { 'select' } let(:described_element) { 'select' } let(:expected_class) { 'govuk-select' } describe '#govuk_collection_select...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/date_spec.rb
Ruby
mit
92
main
13,688
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' describe '#govuk_date_field' do let(:method) { :govuk_date_field } let(:attribute) { :born_on } let(:fieldset_heading) { 'Date of birth' } let(:legend_text) { 'When were you born?' } let(:hint_text) { 'It say...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/text_field_spec.rb
Ruby
mit
92
main
547
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' describe('#govuk_text_field') { it_behaves_like 'a regular input', 'text', 'text' } describe('#govuk_phone_field') { it_behaves_like 'a regular input', 'phone', 'tel' } describe('#govuk_email_field') { it_behaves_li...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/check_boxes/fieldset_spec.rb
Ruby
mit
92
main
6,040
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' describe '#govuk_check_boxes_fieldset' do let(:attribute) { :projects } let(:method) { :govuk_check_boxes_fieldset } let(:field_type) { 'input' } let(:kwargs) { {} } let(:ari...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/check_boxes/collection_spec.rb
Ruby
mit
92
main
6,756
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' describe '#govuk_collection_check_boxes' do let(:attribute) { :projects } let(:method) { :govuk_collection_check_boxes } let(:field_type) { 'input' } let(:aria_described_by_targe...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/check_boxes/check_box_spec.rb
Ruby
mit
92
main
6,947
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' describe '#govuk_check_box' do let(:method) { :govuk_check_box } let(:attribute) { :stationery } let(:value) { ballpoint_pen.id } let(:value_with_dashes) { underscores_to_dashes(...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/time_segment_configuration_spec.rb
Ruby
mit
92
main
1,554
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' after { GOVUKDesignSystemFormBuilder.reset! } describe 'default time segments' do let(:overridden_segments) { { hour: 'c', minute: 'b', second: 'a' } } before do GOVUKDesignSys...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/error_summary_turbo_prefix_configuration_spec.rb
Ruby
mit
92
main
1,041
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' before { object.valid? } subject { builder.govuk_error_summary } describe 'changing the defualt prefix' do let(:new_prefix) { 'turbo' } before do GOVUKDesignSystemFormBuilder...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/radio_divider_configuration_spec.rb
Ruby
mit
92
main
1,364
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' after { GOVUKDesignSystemFormBuilder.reset! } describe 'radio divider config' do specify %(the default should be 'or') do expect(GOVUKDesignSystemFormBuilder.config.default_radio_di...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/error_summary_configuration_spec.rb
Ruby
mit
92
main
1,173
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' after { GOVUKDesignSystemFormBuilder.reset! } describe 'error summary title' do let(:method) { :govuk_error_summary } let(:args) { [method] } let(:default_error_summary_title) { 'H...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/date_segment_configuration_spec.rb
Ruby
mit
92
main
1,538
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' after { GOVUKDesignSystemFormBuilder.reset! } describe 'default date segments' do let(:overridden_segments) { { day: 'c', month: 'b', year: 'a' } } before do GOVUKDesignSystemF...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/submit_configuration_spec.rb
Ruby
mit
92
main
2,381
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' after { GOVUKDesignSystemFormBuilder.reset! } describe 'submit config' do let(:method) { :govuk_submit } let(:args) { [method] } let(:kwargs) { {} } subject { builder.send(*ar...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/logging_spec.rb
Ruby
mit
92
main
856
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' before { object.born_on = { not_a_date: true } } before { allow(Rails).to receive_message_chain(:logger, :warn) } after { GOVUKDesignSystemFormBuilder.reset! } describe 'logging config' do context 'when logging is enabl...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/radio_auto_embolden_label_spec.rb
Ruby
mit
92
main
2,549
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' describe 'labels auto bolding config' do specify %(the default should be to bold labels when hints are present) do expect(GOVUKDesignSystemFormBuilder.config.default_collection_radio_b...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/check_box_divider_configuration_spec.rb
Ruby
mit
92
main
1,406
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' after { GOVUKDesignSystemFormBuilder.reset! } describe 'checkbox divider config' do specify %(the default should be 'or') do expect(GOVUKDesignSystemFormBuilder.config.default_check...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/error_message_prefix_configuration_spec.rb
Ruby
mit
92
main
1,186
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' after { GOVUKDesignSystemFormBuilder.reset! } describe 'error message prefix' do let(:default_error_message_prefix) { 'Error' } let(:method) { :govuk_text_field } let(:attribute) {...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/error_summary_presenter_configuration_spec.rb
Ruby
mit
92
main
1,016
class ErrorSummaryReversePresenter def initialize(error_messages) @error_messages = error_messages end def formatted_error_messages @error_messages.map { |attribute, messages| [attribute, messages.first.reverse] } end end describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup b...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/trust_error_messages_spec.rb
Ruby
mit
92
main
2,210
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' subject { builder.send(*args) } # the hairstyle validation message contains a linebreak `<br/>` in it before { object.valid?(:trust_error_messages) } after { GOVUKDesignSystemFormBuilder...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/localisation_configuration_spec.rb
Ruby
mit
92
main
3,394
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' after { GOVUKDesignSystemFormBuilder.reset! } describe 'localisation config' do let(:args) { [method, attribute] } let(:attribute) { :name } let(:method) { :govuk_text_field } ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/error_summary_error_message_sorting_configuration_spec.rb
Ruby
mit
92
main
830
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' describe 'changing the default error order method' do let(:object) { OrderedErrorsWithCustomOrder.new } let(:custom_method_name) { :error_order } before { object.valid? } subje...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/configuration/legend_configuration_spec.rb
Ruby
mit
92
main
1,916
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' after { GOVUKDesignSystemFormBuilder.reset! } describe 'legend config' do include_context 'setup radios' let(:method) { :govuk_collection_radio_buttons } let(:colours) { Array.wra...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/radios/collection_spec.rb
Ruby
mit
92
main
10,101
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' include_context 'setup radios' describe '#govuk_collection_radio_buttons' do let(:method) { :govuk_collection_radio_buttons } let(:colours) do [ OpenStruct.new(id: 'red',...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/radios/fieldset_spec.rb
Ruby
mit
92
main
6,414
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' include_context 'setup radios' describe '#govuk_radio_buttons_fieldset' do let(:method) { :govuk_radio_buttons_fieldset } let(:args) { [method, attribute] } let(:example_block) do ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
spec/govuk_design_system_formbuilder/builder/radios/radio_button_spec.rb
Ruby
mit
92
main
4,079
describe GOVUKDesignSystemFormBuilder::FormBuilder do include_context 'setup builder' include_context 'setup examples' include_context 'setup radios' describe '#govuk_radio_button' do let(:method) { :govuk_radio_button } let(:value) { :ballpoint_pen } let(:value_with_dashes) { underscores_to_dashes...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/helpers.rb
Ruby
mit
92
main
1,239
require 'rails' require 'action_view' require 'active_model' require 'active_support/core_ext/string' require 'htmlbeautifier' require 'ostruct' require 'slim/erb_converter' Rails.logger = Logger.new($stdout) Dir.glob(File.join('./lib', '**', '*.rb')).sort.each { |f| require f } $LOAD_PATH.unshift(File.expand_path("...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/setup/form_builder_objects.rb
Ruby
mit
92
main
1,368
module Setup module FormBuilderObjects def builder(errors = false) case errors when :fields builder_with_field_errors when :base builder_with_base_errors when :presenters builder_with_presenter_errors else builder_without_errors end end ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/setup/example_data.rb
Ruby
mit
92
main
4,252
module Setup module ExampleData def departments_data_raw <<~DATA department = Struct.new(:id, :name, keyword_init: true) departments = [ department.new(id: 1, name: 'Sales'), department.new(id: 2, name: 'Marketing'), department.new(id: 3, name: 'Finance') ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/file.rb
Ruby
mit
92
main
1,236
module Examples module File def file_upload <<~SNIPPET = f.govuk_file_field :profile_photo, label: { text: 'Identification photograph' }, hint: { text: 'Upload a clear colour photograph of yourself looking straight at the camera' } SNIPPET end def file_upload_javas...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/password.rb
Ruby
mit
92
main
1,063
module Examples module Password def default_password <<~PASSWORD = f.govuk_password_field :password_1, label: { text: "Password" } PASSWORD end def password_with_a_captioned_heading_label_and_hint <<~PASSWORD = f.govuk_password_field(:password_2, label: { tex...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/text_input.rb
Ruby
mit
92
main
2,312
module Examples module TextInput def text_field_with_label_and_hint <<~SNIPPET = f.govuk_text_field :first_name, label: { text: 'First name' }, hint: { text: 'You can find it on your birth certificate' } SNIPPET end def text_field_with_numeric_attributes <<~S...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/radios.rb
Ruby
mit
92
main
3,352
module Examples module Radios def radio_field_with_legend_and_hint <<~SNIPPET = f.govuk_collection_radio_buttons :new_department_id, departments, :id, :name, legend: { text: 'Which department do you work for?' }, hint: { text: 'There should be a sign...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/injecting_content.rb
Ruby
mit
92
main
816
module Examples module InjectingContent def colleciton_radio_buttons_with_injected_content <<~SNIPPET = f.govuk_collection_radio_buttons :department_id, departments, :id, :name, legend: { text: "Which department do you want to nominate?" } do p.fi...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/error_handling.rb
Ruby
mit
92
main
1,732
module Examples module ErrorHandling def form_with_multiple_errors <<~SNIPPET = f.govuk_error_summary h2.govuk-heading-l | Register your interest in becoming a teacher = f.govuk_text_field :welcome_pack_reference_number, width: 10, label: { text: 'What...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/localisation.rb
Ruby
mit
92
main
4,277
module Examples module Localisation def favourite_kind_of_hat_locale <<~LOCALE helpers: label: person: favourite_kind_of_hat: Which style of hat do you prefer? caption: person: favourite_kind_of_hat: Fashion choices hi...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/select.rb
Ruby
mit
92
main
763
module Examples module Select def select_field_with_label_and_hint <<~SNIPPET = f.govuk_collection_select :new_department_id, departments, :id, :name, label: { text: "Which department do you work in?" }, hint: { text: "You can find it on your ID badg...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/labels_captions_hints_and_legends.rb
Ruby
mit
92
main
2,475
module Examples module LabelsCaptionsHintsAndLegends def text_field_with_no_label "= f.govuk_text_field :favourite_colour" end def text_field_with_configured_label <<~SNIPPET = f.govuk_text_field :favourite_shade_of_red, label: { text: 'What is your favourite shade of red?',...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/submit.rb
Ruby
mit
92
main
1,043
module Examples module SubmitButton def submit_button "= f.govuk_submit" end def secondary_button "= f.govuk_submit 'Find address', secondary: true" end def warning_button "= f.govuk_submit 'Delete all records', warning: true" end def inverse_button "= f.govuk_su...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/text_area.rb
Ruby
mit
92
main
782
module Examples module TextArea def text_area "= f.govuk_text_area :responsibilities" end def text_area_with_label_and_hint_and_nine_rows <<~SNIPPET = f.govuk_text_area :job_description, label: { text: 'Job description' }, hint: { text: 'Describe your typical day' ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/date.rb
Ruby
mit
92
main
1,283
module Examples module Date def date_field <<~SNIPPET = f.govuk_date_field :date_of_birth, date_of_birth: true, legend: { text: 'Enter your date of birth' }, hint: { text: 'For example, 31 3 1980' } SNIPPET end def month_field <<~SNIPPET = f...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/checkboxes.rb
Ruby
mit
92
main
3,403
module Examples module Checkboxes def checkbox_field <<~SNIPPET = f.govuk_collection_check_boxes :department_ids, departments, :id, :name, caption: nil, legend: { text: "Which departments do you work in?" }, hint: { text: "Select all depart...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/examples/fieldset.rb
Ruby
mit
92
main
584
module Examples module Radios def address_fieldset <<~SNIPPET = f.govuk_fieldset legend: { text: 'Where do you live?' } do = f.govuk_text_field :address_one, width: 'one-half', label: { text: 'House number and street' } = f.govuk_text_field :address_two, width: 'one-half',...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/helpers/link_helpers.rb
Ruby
mit
92
main
4,442
module Helpers module TitleAnchorHelpers def anchor_id(caption) caption.parameterize end end module LinkHelpers def navigation_links { "Introduction" => { "Get started" => "/introduction/get-started/", "Configuration" => "/introduction/configuration/", ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/helpers/formatters.rb
Ruby
mit
92
main
2,008
module Helpers module Formatters def block_has_content?(block) block.call end def link_to_in_new_tab(*args, **kwargs, &block) new_tab_args = { rel: "noreferrer noopener", target: "_blank" } link_to(*args, **new_tab_args.merge(kwargs), &block) end def format_slim(raw, **args) ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/helpers/person.rb
Ruby
mit
92
main
3,026
require 'active_model' class Person include ActiveModel::Model # string fields attr_accessor( :name, :first_name, :last_name, :job_title, :postcode, :account_number, :price_per_kg, :national_insurance_number_with_spacing, :national_insurance_number_without_spacing, ) # p...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
guide/lib/helpers/related_info.rb
Ruby
mit
92
main
7,097
module Helpers module RelatedInfo def error_handling_info { 'Form builder documentation for the error summary component' => 'https://www.rubydoc.info/gems/govuk_design_system_formbuilder/GOVUKDesignSystemFormBuilder/Builder#govuk_error_summary-instance_method', 'GOV.UK design system error me...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder.rb
Ruby
mit
92
main
8,065
require 'active_support/ordered_options' require 'html_attributes_utils' [%w(presenters *.rb), %w(refinements *.rb), %w(traits *.rb), %w(*.rb), %w(elements ** *.rb), %w(containers ** *.rb)] .flat_map { |matcher| Dir.glob(File.join(__dir__, 'govuk_design_system_formbuilder', *matcher)) } .each { |file| require file...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/builder.rb
Ruby
mit
92
main
78,352
module GOVUKDesignSystemFormBuilder module Builder delegate :config, to: GOVUKDesignSystemFormBuilder # Generates a form label without a form group or input # @param text [String] the label text # @param size [String] the size of the label font, can be +xl+, +l+, +m+, +s+ or nil # @param tag [Sym...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/base.rb
Ruby
mit
92
main
3,368
module GOVUKDesignSystemFormBuilder class Base delegate :content_tag, :safe_join, :tag, :link_to, :capture, to: :@builder delegate :config, to: GOVUKDesignSystemFormBuilder def initialize(builder, object_name, attribute_name, &block) @builder = builder @object_name = object_name ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/proxy.rb
Ruby
mit
92
main
325
require_relative 'base' module GOVUKDesignSystemFormBuilder class Proxy < GOVUKDesignSystemFormBuilder::Base NullBuilder = Struct.new(:object) def initialize(object, object_name, attribute_name, value: nil) super(NullBuilder.new(object), object_name, attribute_name) @value = value end end...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/builder_helper.rb
Ruby
mit
92
main
3,157
module GOVUKDesignSystemFormBuilder # NOTE: this is currently considered experimental, it's likely to change based on feedback. # # BuilderHelper contains methods that expose the form builder's functionality # externally. The objectives are to allow: # # * rendering the error summary outside of the form #...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/refinements/prefixable_array.rb
Ruby
mit
92
main
205
module GOVUKDesignSystemFormBuilder module PrefixableArray refine Array do def prefix(text, delimiter: '-') map { |item| [text, item].join(delimiter.to_s) } end end end end
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/presenters/error_summary.rb
Ruby
mit
92
main
1,940
module Presenters # This is the default presenter for {GOVUKDesignSystemFormBuilder::Elements::ErrorSummary} and is # intended to be easily replaceable should you have specific requirements that aren't met here. # # The basic behaviour is to always show the first error message. In Rails, error message order is ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/caption.rb
Ruby
mit
92
main
993
module GOVUKDesignSystemFormBuilder module Elements class Caption < Base include Traits::Localisation include Traits::HTMLAttributes include Traits::HTMLClasses def initialize(builder, object_name, attribute_name, text: nil, size: config.default_caption_size, **kwargs) super(build...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/file.rb
Ruby
mit
92
main
2,862
module GOVUKDesignSystemFormBuilder module Elements class File < Base using PrefixableArray include Traits::Error include Traits::Hint include Traits::Label include Traits::Supplemental include Traits::HTMLAttributes include Traits::HTMLClasses include Traits::Cont...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/collection_select.rb
Ruby
mit
92
main
1,956
module GOVUKDesignSystemFormBuilder module Elements class CollectionSelect < Base include Traits::Error include Traits::Label include Traits::Hint include Traits::Supplemental include Traits::HTMLAttributes include Traits::Select include Traits::ContentBeforeAndAfter ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/legend.rb
Ruby
mit
92
main
2,003
module GOVUKDesignSystemFormBuilder module Elements class Legend < Base using PrefixableArray include Traits::Caption include Traits::Localisation include Traits::HTMLAttributes include Traits::HTMLClasses def initialize(builder, object_name, attribute_name, text: nil, size: ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/null.rb
Ruby
mit
92
main
276
module GOVUKDesignSystemFormBuilder module Elements class Null < Base def initialize super(nil, nil, nil) end def html nil end def active? false end def hint_id nil end end end end
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/hint.rb
Ruby
mit
92
main
1,468
module GOVUKDesignSystemFormBuilder module Elements class Hint < Base using PrefixableArray include Traits::Localisation include Traits::HTMLAttributes include Traits::HTMLClasses def initialize(builder, object_name, attribute_name, value: nil, text: nil, content: nil, radio: false...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/error_message.rb
Ruby
mit
92
main
718
module GOVUKDesignSystemFormBuilder module Elements class ErrorMessage < Base using PrefixableArray include Traits::Error def html return unless has_errors? tag.p(class: %(#{brand}-error-message), id: error_id) do safe_join([hidden_prefix, message]) end ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/text_area.rb
Ruby
mit
92
main
3,230
module GOVUKDesignSystemFormBuilder module Elements class TextArea < Base using PrefixableArray include Traits::Error include Traits::Hint include Traits::Label include Traits::Supplemental include Traits::HTMLAttributes include Traits::HTMLClasses def initialize(...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/label.rb
Ruby
mit
92
main
2,450
module GOVUKDesignSystemFormBuilder module Elements class Label < Base using PrefixableArray include Traits::Caption include Traits::Localisation include Traits::HTMLAttributes include Traits::HTMLClasses def initialize(builder, object_name, attribute_name, text: nil, value: ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/time.rb
Ruby
mit
92
main
1,687
module GOVUKDesignSystemFormBuilder module Elements class Time < Base using PrefixableArray include Traits::Error include Traits::Hint include Traits::Supplemental include Traits::HTMLClasses include Traits::Localisation include Traits::DateInput include Traits::Co...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/date.rb
Ruby
mit
92
main
2,033
module GOVUKDesignSystemFormBuilder module Elements class Date < Base using PrefixableArray include Traits::Error include Traits::Hint include Traits::Supplemental include Traits::HTMLClasses include Traits::Localisation include Traits::DateInput include Traits::Co...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/error_summary.rb
Ruby
mit
92
main
3,779
# frozen_string_literal: true module GOVUKDesignSystemFormBuilder module Elements class ErrorSummary < Base include Traits::Error include Traits::HTMLAttributes def initialize(builder, object_name, title, link_base_errors_to:, order:, presenter:, **kwargs, &block) super(builder, object...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/password.rb
Ruby
mit
92
main
3,991
module GOVUKDesignSystemFormBuilder module Elements class Password < Base using PrefixableArray include Traits::Error include Traits::Hint include Traits::Label include Traits::HTMLAttributes include Traits::HTMLClasses I18nAttr = Struct.new(:key, :text, :default) ...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/select.rb
Ruby
mit
92
main
1,538
module GOVUKDesignSystemFormBuilder module Elements class Select < Base include Traits::Error include Traits::Label include Traits::Hint include Traits::HTMLAttributes include Traits::Select include Traits::ContentBeforeAndAfter def initialize(builder, object_name, attri...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/submit.rb
Ruby
mit
92
main
2,065
module GOVUKDesignSystemFormBuilder module Elements class Submit < Base using PrefixableArray include Traits::HTMLClasses include Traits::HTMLAttributes def initialize(builder, text, warning:, secondary:, inverse:, prevent_double_click:, validate:, disabled:, **kwargs, &block) sup...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/inputs/url.rb
Ruby
mit
92
main
440
module GOVUKDesignSystemFormBuilder module Elements module Inputs class URL < Base include Traits::Input include Traits::Error include Traits::Hint include Traits::Label include Traits::Supplemental include Traits::HTMLAttributes include Traits::Conten...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/inputs/number.rb
Ruby
mit
92
main
446
module GOVUKDesignSystemFormBuilder module Elements module Inputs class Number < Base include Traits::Input include Traits::Error include Traits::Hint include Traits::Label include Traits::Supplemental include Traits::HTMLAttributes include Traits::Con...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/inputs/phone.rb
Ruby
mit
92
main
444
module GOVUKDesignSystemFormBuilder module Elements module Inputs class Phone < Base include Traits::Input include Traits::Error include Traits::Hint include Traits::Label include Traits::Supplemental include Traits::HTMLAttributes include Traits::Cont...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/inputs/text.rb
Ruby
mit
92
main
442
module GOVUKDesignSystemFormBuilder module Elements module Inputs class Text < Base include Traits::Input include Traits::Error include Traits::Hint include Traits::Label include Traits::Supplemental include Traits::HTMLAttributes include Traits::Conte...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/inputs/email.rb
Ruby
mit
92
main
444
module GOVUKDesignSystemFormBuilder module Elements module Inputs class Email < Base include Traits::Input include Traits::Error include Traits::Hint include Traits::Label include Traits::Supplemental include Traits::HTMLAttributes include Traits::Cont...
github
x-govuk/govuk-form-builder
https://github.com/x-govuk/govuk-form-builder
lib/govuk_design_system_formbuilder/elements/radios/fieldset_radio_button.rb
Ruby
mit
92
main
965
module GOVUKDesignSystemFormBuilder module Elements module Radios class FieldsetRadioButton < Base include Traits::Label include Traits::Hint include Traits::HTMLAttributes include Traits::FieldsetItem def initialize(builder, object_name, attribute_name, value, label...