govuk-design-system-rails 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +7 -0
  2. data/app/helpers/govuk_design_system/accordion_helper.rb +7 -0
  3. data/app/helpers/govuk_design_system/back_link_helper.rb +13 -0
  4. data/app/helpers/govuk_design_system/breadcrumbs_helper.rb +7 -0
  5. data/app/helpers/govuk_design_system/button_helper.rb +71 -0
  6. data/app/helpers/govuk_design_system/checkboxes_helper.rb +8 -0
  7. data/app/helpers/govuk_design_system/components_helper.rb +13 -0
  8. data/app/helpers/govuk_design_system/cookie_banner_helper.rb +7 -0
  9. data/app/helpers/govuk_design_system/date_input_helper.rb +8 -0
  10. data/app/helpers/govuk_design_system/details_helper.rb +32 -0
  11. data/app/helpers/govuk_design_system/error_message_helper.rb +7 -0
  12. data/app/helpers/govuk_design_system/error_summary_helper.rb +20 -0
  13. data/app/helpers/govuk_design_system/fieldset_helper.rb +9 -0
  14. data/app/helpers/govuk_design_system/file_upload_helper.rb +59 -0
  15. data/app/helpers/govuk_design_system/header_helper.rb +7 -0
  16. data/app/helpers/govuk_design_system/hint_helper.rb +7 -0
  17. data/app/helpers/govuk_design_system/hmcts_badge_helper.rb +7 -0
  18. data/app/helpers/govuk_design_system/hmcts_banner_helper.rb +7 -0
  19. data/app/helpers/govuk_design_system/input_helper.rb +8 -0
  20. data/app/helpers/govuk_design_system/inset_text_helper.rb +9 -0
  21. data/app/helpers/govuk_design_system/label_helper.rb +7 -0
  22. data/app/helpers/govuk_design_system/notification_banner_helper.rb +8 -0
  23. data/app/helpers/govuk_design_system/phase_banner_helper.rb +21 -0
  24. data/app/helpers/govuk_design_system/radios_helper.rb +8 -0
  25. data/app/helpers/govuk_design_system/select_helper.rb +8 -0
  26. data/app/helpers/govuk_design_system/skip_link_helper.rb +13 -0
  27. data/app/helpers/govuk_design_system/summary_list_helper.rb +7 -0
  28. data/app/helpers/govuk_design_system/tabs_helper.rb +7 -0
  29. data/app/helpers/govuk_design_system/tag_helper.rb +8 -0
  30. data/app/helpers/govuk_design_system/textarea_helper.rb +8 -0
  31. data/app/helpers/govuk_design_system/warning_text_helper.rb +20 -0
  32. data/app/views/components/_govuk_accordion.html.erb +44 -0
  33. data/app/views/components/_govuk_action_link.html.erb +12 -0
  34. data/app/views/components/_govuk_breadcrumbs.html.erb +25 -0
  35. data/app/views/components/_govuk_checkboxes.html.erb +125 -0
  36. data/app/views/components/_govuk_cookie_banner.html.erb +75 -0
  37. data/app/views/components/_govuk_date_input.html.erb +94 -0
  38. data/app/views/components/_govuk_error_message.html.erb +13 -0
  39. data/app/views/components/_govuk_error_summary.html.erb +32 -0
  40. data/app/views/components/_govuk_fieldset.html.erb +21 -0
  41. data/app/views/components/_govuk_header.html.erb +64 -0
  42. data/app/views/components/_govuk_hint.html.erb +7 -0
  43. data/app/views/components/_govuk_hr.html.erb +1 -0
  44. data/app/views/components/_govuk_input.html.erb +97 -0
  45. data/app/views/components/_govuk_inset_text.html.erb +10 -0
  46. data/app/views/components/_govuk_label.html.erb +18 -0
  47. data/app/views/components/_govuk_notification_banner.html.erb +68 -0
  48. data/app/views/components/_govuk_radios.html.erb +141 -0
  49. data/app/views/components/_govuk_select.html.erb +105 -0
  50. data/app/views/components/_govuk_summary_list.html.erb +39 -0
  51. data/app/views/components/_govuk_tabs.html.erb +46 -0
  52. data/app/views/components/_govuk_textarea.html.erb +70 -0
  53. data/app/views/components/_hmcts_banner.html.erb +33 -0
  54. data/app/views/form_components/_govuk_checkboxes.html.erb +21 -0
  55. data/app/views/form_components/_govuk_date_input.html.erb +32 -0
  56. data/app/views/form_components/_govuk_input.html.erb +11 -0
  57. data/app/views/form_components/_govuk_radios.html.erb +24 -0
  58. data/app/views/form_components/_govuk_select.html.erb +25 -0
  59. data/app/views/form_components/_govuk_textarea.html.erb +11 -0
  60. data/lib/govuk-design-system-rails.rb +1 -0
  61. data/lib/govuk_design_system/engine.rb +50 -0
  62. data/lib/govuk_design_system.rb +4 -0
  63. data/spec/dummy/Rakefile +6 -0
  64. data/spec/dummy/app/assets/config/manifest.js +2 -0
  65. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  66. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  67. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  68. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  69. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  70. data/spec/dummy/app/javascript/packs/application.js +15 -0
  71. data/spec/dummy/app/jobs/application_job.rb +7 -0
  72. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  73. data/spec/dummy/app/models/application_record.rb +3 -0
  74. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  75. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  76. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  77. data/spec/dummy/bin/rails +4 -0
  78. data/spec/dummy/bin/rake +4 -0
  79. data/spec/dummy/bin/setup +33 -0
  80. data/spec/dummy/config/application.rb +38 -0
  81. data/spec/dummy/config/boot.rb +5 -0
  82. data/spec/dummy/config/cable.yml +10 -0
  83. data/spec/dummy/config/database.yml +25 -0
  84. data/spec/dummy/config/environment.rb +5 -0
  85. data/spec/dummy/config/environments/development.rb +76 -0
  86. data/spec/dummy/config/environments/production.rb +120 -0
  87. data/spec/dummy/config/environments/test.rb +59 -0
  88. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
  89. data/spec/dummy/config/initializers/assets.rb +12 -0
  90. data/spec/dummy/config/initializers/backtrace_silencers.rb +8 -0
  91. data/spec/dummy/config/initializers/content_security_policy.rb +28 -0
  92. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  93. data/spec/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  94. data/spec/dummy/config/initializers/inflections.rb +16 -0
  95. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  96. data/spec/dummy/config/initializers/permissions_policy.rb +11 -0
  97. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  98. data/spec/dummy/config/locales/en.yml +33 -0
  99. data/spec/dummy/config/puma.rb +43 -0
  100. data/spec/dummy/config/routes.rb +3 -0
  101. data/spec/dummy/config/storage.yml +34 -0
  102. data/spec/dummy/config.ru +6 -0
  103. data/spec/dummy/db/development.sqlite3 +0 -0
  104. data/spec/dummy/db/test.sqlite3 +0 -0
  105. data/spec/dummy/public/404.html +67 -0
  106. data/spec/dummy/public/422.html +67 -0
  107. data/spec/dummy/public/500.html +66 -0
  108. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  109. data/spec/dummy/public/apple-touch-icon.png +0 -0
  110. data/spec/dummy/public/favicon.ico +0 -0
  111. data/spec/dummy/tmp/development_secret.txt +1 -0
  112. data/spec/helpers/govuk_design_system/accordion_helper_spec.rb +353 -0
  113. data/spec/helpers/govuk_design_system/breadcrumbs_helper_spec.rb +90 -0
  114. data/spec/helpers/govuk_design_system/button_helper_spec.rb +34 -0
  115. data/spec/helpers/govuk_design_system/checkboxes_helper_spec.rb +146 -0
  116. data/spec/helpers/govuk_design_system/cookie_banner_helper_spec.rb +65 -0
  117. data/spec/helpers/govuk_design_system/date_input_helper_spec.rb +63 -0
  118. data/spec/helpers/govuk_design_system/details_helper_spec.rb +42 -0
  119. data/spec/helpers/govuk_design_system/error_message_helper_spec.rb +18 -0
  120. data/spec/helpers/govuk_design_system/error_summary_helper_spec.rb +39 -0
  121. data/spec/helpers/govuk_design_system/header_helper_spec.rb +138 -0
  122. data/spec/helpers/govuk_design_system/hint_helper_spec.rb +20 -0
  123. data/spec/helpers/govuk_design_system/hmcts_badge_helper_spec.rb +16 -0
  124. data/spec/helpers/govuk_design_system/hmcts_banner_helper_spec.rb +59 -0
  125. data/spec/helpers/govuk_design_system/input_helper_spec.rb +157 -0
  126. data/spec/helpers/govuk_design_system/inset_text_helper_spec.rb +58 -0
  127. data/spec/helpers/govuk_design_system/label_helper_spec.rb +21 -0
  128. data/spec/helpers/govuk_design_system/notification_banner_helper_spec.rb +98 -0
  129. data/spec/helpers/govuk_design_system/radios_helper_spec.rb +270 -0
  130. data/spec/helpers/govuk_design_system/select_helper_spec.rb +85 -0
  131. data/spec/helpers/govuk_design_system/summary_list_helper_spec.rb +138 -0
  132. data/spec/helpers/govuk_design_system/tabs_helper_spec.rb +129 -0
  133. data/spec/helpers/govuk_design_system/tag_helper_spec.rb +17 -0
  134. data/spec/helpers/govuk_design_system/textarea_helper_spec.rb +67 -0
  135. data/spec/rails_helper.rb +64 -0
  136. data/spec/spec_helper.rb +116 -0
  137. metadata +401 -0
@@ -0,0 +1,90 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe GovukDesignSystem::BreadcrumbsHelper, type: :helper do
4
+ describe "#govukBreadcrumbs" do
5
+ it "returns the correct HTML for the default example" do
6
+ html = helper.govukBreadcrumbs({
7
+ items: [
8
+ {
9
+ text: "Home",
10
+ href: "#"
11
+ },
12
+ {
13
+ text: "Passports, travel and living abroad",
14
+ href: "#"
15
+ },
16
+ {
17
+ text: "Travel abroad",
18
+ href: "#"
19
+ }
20
+ ]
21
+ })
22
+
23
+ expect(html).to match_html(<<~HTML)
24
+ <div class="govuk-breadcrumbs">
25
+ <ol class="govuk-breadcrumbs__list">
26
+ <li class="govuk-breadcrumbs__list-item">
27
+ <a class="govuk-breadcrumbs__link" href="#">Home</a>
28
+ </li>
29
+ <li class="govuk-breadcrumbs__list-item">
30
+ <a class="govuk-breadcrumbs__link" href="#">Passports, travel and living abroad</a>
31
+ </li>
32
+ <li class="govuk-breadcrumbs__list-item">
33
+ <a class="govuk-breadcrumbs__link" href="#">Travel abroad</a>
34
+ </li>
35
+ </ol>
36
+ </div>
37
+ HTML
38
+ end
39
+
40
+ it "allows a collapsing on mobile" do
41
+ html = helper.govukBreadcrumbs({
42
+ collapseOnMobile: true,
43
+ items: [
44
+ {
45
+ text: "Home",
46
+ href: "#"
47
+ },
48
+ {
49
+ text: "Environment",
50
+ href: "#"
51
+ },
52
+ {
53
+ text: "Rural and countryside",
54
+ href: "#"
55
+ },
56
+ {
57
+ text: "Rural development and land management",
58
+ href: "#"
59
+ },
60
+ {
61
+ text: "Economic growth in rural areas",
62
+ href: "#"
63
+ }
64
+ ]
65
+ })
66
+
67
+ expect(html).to match_html(<<~HTML)
68
+ <div class="govuk-breadcrumbs govuk-breadcrumbs--collapse-on-mobile">
69
+ <ol class="govuk-breadcrumbs__list">
70
+ <li class="govuk-breadcrumbs__list-item">
71
+ <a class="govuk-breadcrumbs__link" href="#">Home</a>
72
+ </li>
73
+ <li class="govuk-breadcrumbs__list-item">
74
+ <a class="govuk-breadcrumbs__link" href="#">Environment</a>
75
+ </li>
76
+ <li class="govuk-breadcrumbs__list-item">
77
+ <a class="govuk-breadcrumbs__link" href="#">Rural and countryside</a>
78
+ </li>
79
+ <li class="govuk-breadcrumbs__list-item">
80
+ <a class="govuk-breadcrumbs__link" href="#">Rural development and land management</a>
81
+ </li>
82
+ <li class="govuk-breadcrumbs__list-item">
83
+ <a class="govuk-breadcrumbs__link" href="#">Economic growth in rural areas</a>
84
+ </li>
85
+ </ol>
86
+ </div>
87
+ HTML
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,34 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe GovukDesignSystem::ButtonHelper, type: :helper do
4
+ describe "#govukButton" do
5
+ it "returns the correct HTML for the default example" do
6
+ html = helper.govukButton({
7
+ text: "Save and continue"
8
+ })
9
+
10
+ expect(html).to match_html(<<~HTML)
11
+ <button class="govuk-button" data-module="govuk-button">
12
+ Save and continue
13
+ </button>
14
+ HTML
15
+ end
16
+
17
+ it "produces start buttons with an href as link" do
18
+ html = helper.govukButton({
19
+ text: "Start now",
20
+ href: "#",
21
+ isStartButton: true
22
+ })
23
+
24
+ expect(html).to match_html(<<~HTML)
25
+ <a href="#" role="button" draggable="false" class="govuk-button govuk-button--start" data-module="govuk-button">
26
+ Start now
27
+ <svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
28
+ <path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
29
+ </svg>
30
+ </a>
31
+ HTML
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,146 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe GovukDesignSystem::CheckboxesHelper, type: :helper do
4
+ describe "#govukCheckboxes" do
5
+ it "returns the correct HTML for the default example" do
6
+ html = helper.govukCheckboxes({
7
+ idPrefix: "waste",
8
+ name: "waste",
9
+ fieldset: {
10
+ legend: {
11
+ text: "Which types of waste do you transport?",
12
+ isPageHeading: true,
13
+ classes: "govuk-fieldset__legend--l"
14
+ }
15
+ },
16
+ hint: {
17
+ text: "Select all that apply."
18
+ },
19
+ items: [
20
+ {
21
+ value: "carcasses",
22
+ text: "Waste from animal carcasses",
23
+ disable_ghost: true
24
+ },
25
+ {
26
+ value: "mines",
27
+ text: "Waste from mines or quarries",
28
+ disable_ghost: true
29
+ },
30
+ {
31
+ value: "farm",
32
+ text: "Farm or agricultural waste",
33
+ disable_ghost: true
34
+ }
35
+ ]
36
+ })
37
+
38
+ expect(html).to match_html(<<~HTML)
39
+ <div class="govuk-form-group">
40
+ <fieldset class="govuk-fieldset" aria-describedby="waste-hint">
41
+ <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
42
+ <h1 class="govuk-fieldset__heading">
43
+ Which types of waste do you transport?
44
+ </h1>
45
+ </legend>
46
+ <div id="waste-hint" class="govuk-hint">
47
+ Select all that apply.
48
+ </div>
49
+ <div class="govuk-checkboxes" data-module="govuk-checkboxes">
50
+ <div class="govuk-checkboxes__item">
51
+ <input class="govuk-checkboxes__input" id="waste" name="waste" type="checkbox" value="carcasses">
52
+ <label class="govuk-label govuk-checkboxes__label" for="waste">
53
+ Waste from animal carcasses
54
+ </label>
55
+ </div>
56
+ <div class="govuk-checkboxes__item">
57
+ <input class="govuk-checkboxes__input" id="waste-2" name="waste" type="checkbox" value="mines">
58
+ <label class="govuk-label govuk-checkboxes__label" for="waste-2">
59
+ Waste from mines or quarries
60
+ </label>
61
+ </div>
62
+ <div class="govuk-checkboxes__item">
63
+ <input class="govuk-checkboxes__input" id="waste-3" name="waste" type="checkbox" value="farm">
64
+ <label class="govuk-label govuk-checkboxes__label" for="waste-3">
65
+ Farm or agricultural waste
66
+ </label>
67
+ </div>
68
+ </div>
69
+
70
+ </fieldset>
71
+ </div>
72
+ HTML
73
+ end
74
+
75
+ it "adds ghost inputs by default as required by Rails" do
76
+ # NOTE: https://github.com/govuk-ruby/govuk-design-system-rails/blob/master/README.md#component-implementations
77
+ html = helper.govukCheckboxes({
78
+ idPrefix: "waste",
79
+ name: "waste",
80
+ fieldset: {
81
+ legend: {
82
+ text: "Which types of waste do you transport?",
83
+ isPageHeading: true,
84
+ classes: "govuk-fieldset__legend--l"
85
+ }
86
+ },
87
+ hint: {
88
+ text: "Select all that apply."
89
+ },
90
+ items: [
91
+ {
92
+ value: "carcasses",
93
+ text: "Waste from animal carcasses",
94
+ },
95
+ {
96
+ value: "mines",
97
+ text: "Waste from mines or quarries",
98
+ },
99
+ {
100
+ value: "farm",
101
+ text: "Farm or agricultural waste",
102
+ }
103
+ ]
104
+ })
105
+
106
+ expect(html).to match_html(<<~HTML)
107
+ <div class="govuk-form-group">
108
+ <fieldset class="govuk-fieldset" aria-describedby="waste-hint">
109
+ <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
110
+ <h1 class="govuk-fieldset__heading">
111
+ Which types of waste do you transport?
112
+ </h1>
113
+ </legend>
114
+ <div id="waste-hint" class="govuk-hint">
115
+ Select all that apply.
116
+ </div>
117
+ <div class="govuk-checkboxes" data-module="govuk-checkboxes">
118
+ <input type="hidden" value="0" name="waste">
119
+ <div class="govuk-checkboxes__item">
120
+ <input class="govuk-checkboxes__input" id="waste" name="waste" type="checkbox" value="carcasses">
121
+ <label class="govuk-label govuk-checkboxes__label" for="waste">
122
+ Waste from animal carcasses
123
+ </label>
124
+ </div>
125
+ <input type="hidden" value="0" name="waste">
126
+ <div class="govuk-checkboxes__item">
127
+ <input class="govuk-checkboxes__input" id="waste-2" name="waste" type="checkbox" value="mines">
128
+ <label class="govuk-label govuk-checkboxes__label" for="waste-2">
129
+ Waste from mines or quarries
130
+ </label>
131
+ </div>
132
+ <input type="hidden" value="0" name="waste">
133
+ <div class="govuk-checkboxes__item">
134
+ <input class="govuk-checkboxes__input" id="waste-3" name="waste" type="checkbox" value="farm">
135
+ <label class="govuk-label govuk-checkboxes__label" for="waste-3">
136
+ Farm or agricultural waste
137
+ </label>
138
+ </div>
139
+ </div>
140
+
141
+ </fieldset>
142
+ </div>
143
+ HTML
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,65 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe GovukDesignSystem::CookieBannerHelper, type: :helper do
4
+ describe "#govukCookieBanner" do
5
+ it "returns the correct HTML for the default example" do
6
+ html = helper.govukCookieBanner({
7
+ ariaLabel: "Cookies on [name of service]",
8
+ messages: [
9
+ {
10
+ headingText: "Cookies on [name of service]",
11
+ html: <<~HTML.html_safe,
12
+ <p class="govuk-body">We use some essential cookies to make this service work.</p>
13
+ <p class="govuk-body">We’d also like to use analytics cookies so we can understand how you use the service and make improvements.</p>
14
+ HTML
15
+ actions: [
16
+ {
17
+ text: "Accept analytics cookies",
18
+ type: "button",
19
+ name: "cookies",
20
+ value: "accept"
21
+ },
22
+ {
23
+ text: "Reject analytics cookies",
24
+ type: "button",
25
+ name: "cookies",
26
+ value: "reject"
27
+ },
28
+ {
29
+ text: "View cookies",
30
+ href: "#"
31
+ }
32
+ ]
33
+ }
34
+ ]
35
+ })
36
+
37
+ expect(html).to match_html(<<~HTML)
38
+ <div class="govuk-cookie-banner" data-nosnippet="true" role="region" aria-label="Cookies on [name of service]">
39
+ <div class="govuk-cookie-banner__message govuk-width-container">
40
+
41
+ <div class="govuk-grid-row">
42
+ <div class="govuk-grid-column-two-thirds">
43
+ <h2 class="govuk-cookie-banner__heading govuk-heading-m">Cookies on [name of service]</h2>
44
+
45
+ <div class="govuk-cookie-banner__content">
46
+ <p class="govuk-body">We use some essential cookies to make this service work.</p>
47
+ <p class="govuk-body">We’d also like to use analytics cookies so we can understand how you use the service and make improvements.</p>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <div class="govuk-button-group">
52
+ <button value="accept" type="button" name="cookies" class="govuk-button" data-module="govuk-button">
53
+ Accept analytics cookies
54
+ </button>
55
+ <button value="reject" type="button" name="cookies" class="govuk-button" data-module="govuk-button">
56
+ Reject analytics cookies
57
+ </button>
58
+ <a class="govuk-link" href="#">View cookies</a>
59
+ </div>
60
+ </div>
61
+ </div>
62
+ HTML
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,63 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe GovukDesignSystem::DateInputHelper, type: :helper do
4
+ describe "#govukDateInput" do
5
+ it "returns the correct HTML for the default example" do
6
+ html = helper.govukDateInput({
7
+ id: "passport-issued",
8
+ namePrefix: "passport-issued",
9
+ fieldset: {
10
+ legend: {
11
+ text: "When was your passport issued?",
12
+ isPageHeading: true,
13
+ classes: "govuk-fieldset__legend--l"
14
+ }
15
+ },
16
+ hint: {
17
+ text: "For example, 27 3 2007"
18
+ }
19
+ })
20
+
21
+ expect(html).to match_html(<<~HTML)
22
+ <div class="govuk-form-group">
23
+ <fieldset class="govuk-fieldset" role="group" aria-describedby="passport-issued-hint">
24
+ <legend class="govuk-fieldset__legend govuk-fieldset__legend--l">
25
+ <h1 class="govuk-fieldset__heading">
26
+ When was your passport issued?
27
+ </h1>
28
+ </legend>
29
+ <div id="passport-issued-hint" class="govuk-hint">
30
+ For example, 27 3 2007
31
+ </div>
32
+ <div class="govuk-date-input" id="passport-issued">
33
+ <div class="govuk-date-input__item">
34
+ <div class="govuk-form-group">
35
+ <label class="govuk-label govuk-date-input__label" for="passport-issued-day">
36
+ Day
37
+ </label>
38
+ <input class="govuk-input govuk-date-input__input govuk-input--width-2" id="passport-issued-day" name="passport-issued-day" type="text" inputmode="numeric" pattern="[0-9]*">
39
+ </div>
40
+ </div>
41
+ <div class="govuk-date-input__item">
42
+ <div class="govuk-form-group">
43
+ <label class="govuk-label govuk-date-input__label" for="passport-issued-month">
44
+ Month
45
+ </label>
46
+ <input class="govuk-input govuk-date-input__input govuk-input--width-2" id="passport-issued-month" name="passport-issued-month" type="text" inputmode="numeric" pattern="[0-9]*">
47
+ </div>
48
+ </div>
49
+ <div class="govuk-date-input__item">
50
+ <div class="govuk-form-group">
51
+ <label class="govuk-label govuk-date-input__label" for="passport-issued-year">
52
+ Year
53
+ </label>
54
+ <input class="govuk-input govuk-date-input__input govuk-input--width-4" id="passport-issued-year" name="passport-issued-year" type="text" inputmode="numeric" pattern="[0-9]*">
55
+ </div>
56
+ </div>
57
+ </div>
58
+ </fieldset>
59
+ </div>
60
+ HTML
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,42 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe GovukDesignSystem::DetailsHelper, type: :helper do
4
+ describe "#govukDetails" do
5
+ it "returns the correct HTML for the default example" do
6
+ html = helper.govukDetails({
7
+ summaryText: "Help with nationality",
8
+ text: "We need to know your nationality so we can work out which elections you’re entitled to vote in. If you cannot provide your nationality, you’ll have to send copies of identity documents through the post."
9
+ })
10
+
11
+ expect(html).to match_html(<<~HTML)
12
+ <details class="govuk-details" data-module="govuk-details">
13
+ <summary class="govuk-details__summary">
14
+ <span class="govuk-details__summary-text">
15
+ Help with nationality
16
+ </span>
17
+ </summary>
18
+ <div class="govuk-details__text">
19
+ We need to know your nationality so we can work out which elections you’re entitled to vote in. If you cannot provide your nationality, you’ll have to send copies of identity documents through the post.
20
+ </div>
21
+ </details>
22
+ HTML
23
+ end
24
+
25
+ it "accepts a block to generate the HTML" do
26
+ html = helper.govukDetails({ summaryText: "Testing block generation" }) { "Inner HTML" }
27
+
28
+ expect(html).to match_html(<<~HTML)
29
+ <details class="govuk-details" data-module="govuk-details">
30
+ <summary class="govuk-details__summary">
31
+ <span class="govuk-details__summary-text">
32
+ Testing block generation
33
+ </span>
34
+ </summary>
35
+ <div class="govuk-details__text">
36
+ Inner HTML
37
+ </div>
38
+ </details>
39
+ HTML
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,18 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe GovukDesignSystem::ErrorMessageHelper, type: :helper do
4
+ describe "#govukErrorMessage" do
5
+ it "returns the correct HTML for the default example" do
6
+ html = helper.govukErrorMessage({
7
+ text: "Rhowch eich enw llawn",
8
+ visuallyHiddenText: "Gwall"
9
+ })
10
+
11
+ expect(html).to match_html(<<~HTML)
12
+ <p class="govuk-error-message">
13
+ <span class="govuk-visually-hidden">Gwall:</span> Rhowch eich enw llawn
14
+ </p>
15
+ HTML
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,39 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe GovukDesignSystem::ErrorSummaryHelper, type: :helper do
4
+ describe "#govukErrorSummary" do
5
+ it "returns the correct HTML for the default example" do
6
+ html = helper.govukErrorSummary({
7
+ titleText: "There is a problem",
8
+ errorList: [
9
+ {
10
+ text: "The date your passport was issued must be in the past",
11
+ href: "#passport-issued-day"
12
+ },
13
+ {
14
+ text: "Enter a postcode, like AA1 1AA",
15
+ href: "#postcode-input"
16
+ }
17
+ ]
18
+ })
19
+
20
+ expect(html).to match_html(<<~HTML)
21
+ <div class="govuk-error-summary" aria-labelledby="error-summary-title" role="alert" data-module="govuk-error-summary">
22
+ <h2 class="govuk-error-summary__title" id="error-summary-title">
23
+ There is a problem
24
+ </h2>
25
+ <div class="govuk-error-summary__body">
26
+ <ul class="govuk-list govuk-error-summary__list">
27
+ <li>
28
+ <a href="#passport-issued-day">The date your passport was issued must be in the past</a>
29
+ </li>
30
+ <li>
31
+ <a href="#postcode-input">Enter a postcode, like AA1 1AA</a>
32
+ </li>
33
+ </ul>
34
+ </div>
35
+ </div>
36
+ HTML
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,138 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe GovukDesignSystem::HeaderHelper, type: :helper do
4
+ describe "#govukHeader" do
5
+ it "with only homepageUrl defined" do
6
+ html = helper.govukHeader({
7
+ homepageUrl: "/home"
8
+ })
9
+
10
+ expect(html).to match_html(<<~HTML)
11
+ <header class="govuk-header" role="banner" data-module="govuk-header">
12
+ <div class="govuk-header__container govuk-width-container">
13
+ <div class="govuk-header__logo">
14
+ <a href="/home" class="govuk-header__link govuk-header__link--homepage">
15
+ <span class="govuk-header__logotype">
16
+ <svg aria-hidden="true" focusable="false" class="govuk-header__logotype-crown" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 132 97" height="30" width="36">
17
+ <path fill="currentColor" fill-rule="evenodd" d="M25 30.2c3.5 1.5 7.7-.2 9.1-3.7 1.5-3.6-.2-7.8-3.9-9.2-3.6-1.4-7.6.3-9.1 3.9-1.4 3.5.3 7.5 3.9 9zM9 39.5c3.6 1.5 7.8-.2 9.2-3.7 1.5-3.6-.2-7.8-3.9-9.1-3.6-1.5-7.6.2-9.1 3.8-1.4 3.5.3 7.5 3.8 9zM4.4 57.2c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.5-1.5-7.6.3-9.1 3.8-1.4 3.5.3 7.6 3.9 9.1zm38.3-21.4c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.6-1.5-7.6.3-9.1 3.8-1.3 3.6.4 7.7 3.9 9.1zm64.4-5.6c-3.6 1.5-7.8-.2-9.1-3.7-1.5-3.6.2-7.8 3.8-9.2 3.6-1.4 7.7.3 9.2 3.9 1.3 3.5-.4 7.5-3.9 9zm15.9 9.3c-3.6 1.5-7.7-.2-9.1-3.7-1.5-3.6.2-7.8 3.7-9.1 3.6-1.5 7.7.2 9.2 3.8 1.5 3.5-.3 7.5-3.8 9zm4.7 17.7c-3.6 1.5-7.8-.2-9.2-3.8-1.5-3.6.2-7.7 3.9-9.1 3.6-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.9 2.2 21.1-4.7-2.6-11.9.1-7.7 8.8 2.3-5.5 7.1-4.2 8.1.5.7 3.3-1.3 7.1-5.7 7.9-3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z"></path>
18
+ </svg>
19
+ <span class="govuk-header__logotype-text">
20
+ GOV.UK
21
+ </span>
22
+ </span>
23
+ </a>
24
+ </div>
25
+ </div>
26
+ </header>
27
+ HTML
28
+ end
29
+
30
+ it "with homepageUrl, serviceName and serviceUrl defined" do
31
+ html = helper.govukHeader({
32
+ homepageUrl: "/home",
33
+ serviceName: "Name of the Service",
34
+ serviceUrl: "https://serviceurl.gov.uk"
35
+ })
36
+
37
+ expect(html).to match_html(<<~HTML)
38
+ <header class="govuk-header" role="banner" data-module="govuk-header">
39
+ <div class="govuk-header__container govuk-width-container">
40
+ <div class="govuk-header__logo">
41
+ <a href="/home" class="govuk-header__link govuk-header__link--homepage">
42
+ <span class="govuk-header__logotype">
43
+ <svg aria-hidden="true" focusable="false" class="govuk-header__logotype-crown" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 132 97" height="30" width="36">
44
+ <path fill="currentColor" fill-rule="evenodd" d="M25 30.2c3.5 1.5 7.7-.2 9.1-3.7 1.5-3.6-.2-7.8-3.9-9.2-3.6-1.4-7.6.3-9.1 3.9-1.4 3.5.3 7.5 3.9 9zM9 39.5c3.6 1.5 7.8-.2 9.2-3.7 1.5-3.6-.2-7.8-3.9-9.1-3.6-1.5-7.6.2-9.1 3.8-1.4 3.5.3 7.5 3.8 9zM4.4 57.2c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.5-1.5-7.6.3-9.1 3.8-1.4 3.5.3 7.6 3.9 9.1zm38.3-21.4c3.5 1.5 7.7-.2 9.1-3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 7.9-2 7.2 3.1-.6 4.3-6.4 7.8-13.5 7.2-10.3-.9-10.9-8-11.2-13.8 2.5-.5 7.1 1.8 11 7.3L80.2 60c-4.1 4.4-8 5.3-12.3 5.4 1.4-4.4 8-11.6 8-11.6H55.5s6.4 7.2 7.9 11.6c-4.2-.1-8-1-12.3-5.4l1.4 16.4c3.9-5.5 8.5-7.7 10.9-7.3-.3 5.8-.9 12.8-11.1 13.8-7.2.6-12.9-2.9-13.5-7.2-.7-5 3.8-8.3 7.1-3.1 2.7-8.7-4.6-11.6-9.4-6.2 3.7-8.5 3.6-14.7-4.6-20.8-5.8 7.6-5 13.9 2.2 21.1-4.7-2.6-11.9.1-7.7 8.8 2.3-5.5 7.1-4.2 8.1.5.7 3.3-1.3 7.1-5.7 7.9-3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z"></path>
45
+ </svg>
46
+ <span class="govuk-header__logotype-text">
47
+ GOV.UK
48
+ </span>
49
+ </span>
50
+ </a>
51
+ </div>
52
+ <div class="govuk-header__content">
53
+ <a href="https://serviceurl.gov.uk" class="govuk-header__link govuk-header__link--service-name">
54
+ Name of the Service
55
+ </a>
56
+ </div>
57
+ </div>
58
+ </header>
59
+ HTML
60
+ end
61
+
62
+ it "with homepageUrl, serviceName, serviceUrl and navigation items defined" do
63
+ html = helper.govukHeader({
64
+ homepageUrl: "/home",
65
+ serviceName: "Service name",
66
+ serviceUrl: "https://serviceurl.gov.uk",
67
+ navigation: [
68
+ {
69
+ href: "#1",
70
+ text: "Navigation item 1",
71
+ active: true
72
+ },
73
+ {
74
+ href: "#2",
75
+ text: "Navigation item 2"
76
+ },
77
+ {
78
+ href: "#3",
79
+ text: "Navigation item 3"
80
+ },
81
+ {
82
+ href: "#4",
83
+ text: "Navigation item 4"
84
+ }
85
+ ]
86
+ })
87
+
88
+ expect(html).to match_html(<<~HTML)
89
+ <header class="govuk-header" role="banner" data-module="govuk-header">
90
+ <div class="govuk-header__container govuk-width-container">
91
+ <div class="govuk-header__logo">
92
+ <a href="/home" class="govuk-header__link govuk-header__link--homepage">
93
+ <span class="govuk-header__logotype">
94
+ <svg aria-hidden="true" focusable="false" class="govuk-header__logotype-crown" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 132 97" height="30" width="36">
95
+ <path fill="currentColor" fill-rule="evenodd" d="M25 30.2c3.5 1.5 7.7-.2 9.1-3.7 1.5-3.6-.2-7.8-3.9-9.2-3.6-1.4-7.6.3-9.1 3.9-1.4 3.5.3 7.5 3.9 9zM9 39.5c3.6 1.5 7.8-.2 9.2-3.7 1.5-3.6-.2-7.8-3.9-9.1-3.6-1.5-7.6.2-9.1 3.8-1.4 3.5.3 7.5 3.8 9zM4.4 57.2c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.5-1.5-7.6.3-9.1 3.8-1.4 3.5.3 7.6 3.9 9.1zm38.3-21.4c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.6-1.5-7.6.3-9.1 3.8-1.3 3.6.4 7.7 3.9 9.1zm64.4-5.6c-3.6 1.5-7.8-.2-9.1-3.7-1.5-3.6.2-7.8 3.8-9.2 3.6-1.4 7.7.3 9.2 3.9 1.3 3.5-.4 7.5-3.9 9zm15.9 9.3c-3.6 1.5-7.7-.2-9.1-3.7-1.5-3.6.2-7.8 3.7-9.1 3.6-1.5 7.7.2 9.2 3.8 1.5 3.5-.3 7.5-3.8 9zm4.7 17.7c-3.6 1.5-7.8-.2-9.2-3.8-1.5-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.3 3.5-.4 7.6-3.9 9.1zM89.3 35.8c-3.6 1.5-7.8-.2-9.2-3.8-1.4-3.6.2-7.7 3.9-9.1 3.6-1.5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4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z"></path>
96
+ </svg>
97
+ <span class="govuk-header__logotype-text">
98
+ GOV.UK
99
+ </span>
100
+ </span>
101
+ </a>
102
+ </div>
103
+ <div class="govuk-header__content">
104
+ <a href="https://serviceurl.gov.uk" class="govuk-header__link govuk-header__link--service-name">
105
+ Service name
106
+ </a>
107
+ <nav aria-label="Menu" class="govuk-header__navigation">
108
+ <button type="button" class="govuk-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="Show or hide menu" hidden>Menu</button>
109
+ <ul id="navigation" class="govuk-header__navigation-list">
110
+ <li class="govuk-header__navigation-item govuk-header__navigation-item--active">
111
+ <a class="govuk-header__link" href="#1">
112
+ Navigation item 1
113
+ </a>
114
+ </li>
115
+ <li class="govuk-header__navigation-item">
116
+ <a class="govuk-header__link" href="#2">
117
+ Navigation item 2
118
+ </a>
119
+ </li>
120
+ <li class="govuk-header__navigation-item">
121
+ <a class="govuk-header__link" href="#3">
122
+ Navigation item 3
123
+ </a>
124
+ </li>
125
+ <li class="govuk-header__navigation-item">
126
+ <a class="govuk-header__link" href="#4">
127
+ Navigation item 4
128
+ </a>
129
+ </li>
130
+ </ul>
131
+ </nav>
132
+ </div>
133
+ </div>
134
+ </header>
135
+ HTML
136
+ end
137
+ end
138
+ end