bbc-a11y 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/README.md +9 -11
  4. data/Rakefile +2 -2
  5. data/a11y.rb +5 -0
  6. data/bbc-a11y.gemspec +3 -5
  7. data/bin/a11y +2 -2
  8. data/examples/bbc-pages/a11y.rb +2 -6
  9. data/examples/local-web-app/Gemfile +1 -1
  10. data/examples/local-web-app/a11y.rb +10 -22
  11. data/features/check_standards/focusable_controls.feature +62 -0
  12. data/features/check_standards/form_interactions.feature +45 -0
  13. data/features/check_standards/form_labels.feature +55 -0
  14. data/features/check_standards/headings.feature +154 -0
  15. data/features/check_standards/image_alt.feature +39 -0
  16. data/features/check_standards/language.feature +46 -0
  17. data/features/check_standards/main_landmark.feature +39 -0
  18. data/features/check_standards/tab_index.feature +54 -0
  19. data/features/cli/display_failing_result.feature +10 -0
  20. data/features/{exit_status.feature → cli/exit_status.feature} +1 -2
  21. data/features/cli/provide_muting_tips.feature +25 -0
  22. data/features/cli/report_configuration_errors.feature +43 -0
  23. data/features/cli/skipping_standards.feature +15 -0
  24. data/features/cli/specify_url.feature +9 -0
  25. data/features/cli/specify_url_via_config.feature +13 -0
  26. data/features/mute_errors.feature +118 -0
  27. data/features/step_definitions/steps.rb +25 -1
  28. data/lib/bbc/a11y/cli.rb +32 -44
  29. data/lib/bbc/a11y/configuration.rb +56 -22
  30. data/lib/bbc/a11y/linter.rb +42 -0
  31. data/lib/bbc/a11y/standards.rb +43 -0
  32. data/lib/bbc/a11y/standards/anchor_hrefs.rb +18 -0
  33. data/lib/bbc/a11y/standards/content_follows_headings.rb +22 -0
  34. data/lib/bbc/a11y/standards/exactly_one_main_heading.rb +20 -0
  35. data/lib/bbc/a11y/standards/exactly_one_main_landmark.rb +20 -0
  36. data/lib/bbc/a11y/standards/form_labels.rb +39 -0
  37. data/lib/bbc/a11y/standards/form_submit_buttons.rb +21 -0
  38. data/lib/bbc/a11y/standards/heading_hierarchy.rb +34 -0
  39. data/lib/bbc/a11y/standards/image_alt.rb +18 -0
  40. data/lib/bbc/a11y/standards/language_attribute.rb +19 -0
  41. data/lib/bbc/a11y/standards/tab_index.rb +22 -0
  42. data/lib/bbc/a11y/version +1 -1
  43. data/spec/bbc/a11y/cli_spec.rb +22 -15
  44. data/spec/bbc/a11y/configuration_spec.rb +15 -40
  45. data/standards/support/capybara.rb +1 -2
  46. metadata +62 -81
  47. data/features/specify_url_via_cli.feature +0 -10
  48. data/features/specify_url_via_config.feature +0 -16
  49. data/lib/bbc/a11y.rb +0 -17
  50. data/lib/bbc/a11y/cucumber_runner.rb +0 -208
  51. data/lib/bbc/a11y/cucumber_support.rb +0 -56
  52. data/lib/bbc/a11y/cucumber_support/disabled_w3c.rb +0 -37
  53. data/lib/bbc/a11y/cucumber_support/heading_hierarchy.rb +0 -94
  54. data/lib/bbc/a11y/cucumber_support/language_detector.rb +0 -26
  55. data/lib/bbc/a11y/cucumber_support/matchers.rb +0 -21
  56. data/lib/bbc/a11y/cucumber_support/page.rb +0 -94
  57. data/lib/bbc/a11y/cucumber_support/per_page_checks.rb +0 -28
  58. data/lib/bbc/a11y/cucumber_support/w3c.rb +0 -36
  59. data/spec/bbc/a11y/cucumber_support/heading_hierarchy_spec.rb +0 -162
  60. data/spec/bbc/a11y/cucumber_support/matchers_spec.rb +0 -52
  61. data/spec/bbc/a11y/cucumber_support/page_spec.rb +0 -197
@@ -0,0 +1,34 @@
1
+ module BBC
2
+ module A11y
3
+ module Standards
4
+
5
+ class HeadingHierarchy
6
+ def initialize(page)
7
+ @page = page
8
+ end
9
+
10
+ def call(errors)
11
+ heading_levels.each_cons(2).each do |pair|
12
+ if pair.last > pair.first + 1
13
+ errors << "Headings are not in order: " +
14
+ "h#{pair.first} is followed by h#{pair.last}"
15
+ end
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def headings
22
+ @page.all('h1, h2, h3, h4, h5, h6', visible: false)
23
+ end
24
+
25
+ def heading_levels
26
+ headings.map do |heading|
27
+ heading.tag_name[1].to_i
28
+ end
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,18 @@
1
+ module BBC
2
+ module A11y
3
+ module Standards
4
+ class ImageAlt
5
+ def initialize(page)
6
+ @page = page
7
+ end
8
+
9
+ def call(errors)
10
+ @page.all("img:not([alt])").each do |img|
11
+ errors << "Image has no alt attribute (src=\"#{img['src']}\")"
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ module BBC
2
+ module A11y
3
+ module Standards
4
+ class LanguageAttribute
5
+ def initialize(page)
6
+ @page = page
7
+ end
8
+
9
+ def call(errors)
10
+ @page.all("html:not([lang])").each do |html|
11
+ errors << "The main language must be specified. " +
12
+ "<html> tag has no lang attribute."
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ module BBC
2
+ module A11y
3
+ module Standards
4
+ class TabIndex
5
+ def initialize(page)
6
+ @page = page
7
+ end
8
+
9
+ def call(errors)
10
+ offenders = @page.all("*[tabindex='0']").reject { |el|
11
+ ['input', 'button', 'select', 'textarea', 'a'].include? el.tag_name
12
+ }
13
+ offenders.each do |el|
14
+ errors << "tabindex=\"0\" must not be used on <#{el.tag_name}> " +
15
+ "elements (not focusable by default)"
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.0.13
@@ -3,24 +3,31 @@ require 'bbc/a11y/cli'
3
3
  module BBC
4
4
  module A11y
5
5
  describe CLI do
6
- it "uses a single URL from the CLI args if given" do
7
- runner = double
8
- expect(runner).to receive(:new) do |settings, cucumber_args|
9
- expect(settings.pages.length).to eq 1
10
- expect(settings.pages[0].url).to eq "http://foo.com"
11
- double(call: nil)
12
- end
13
- CLI.new(double, double, double, ["http://foo.com"]).call(runner)
6
+ let(:runner) { double }
7
+ let(:stdout) { double(puts: nil) }
8
+ let(:stdin) { double(puts: nil) }
9
+ let(:stderr) { StringIO.new }
10
+
11
+ def run(args = [])
12
+ CLI.new(stdin, stdout, stderr, args).call
14
13
  end
15
14
 
16
- it "splits a11y and cucumber args" do
17
- runner = double
18
- expect(runner).to receive(:new) do |settings, cucumber_args|
19
- expect(settings.pages.length).to eq 1
20
- expect(cucumber_args).to eq ["--tags", "~@wip"]
21
- double(call: nil)
15
+ context "if the configuration fails to parse" do
16
+ before do
17
+ allow(Configuration).to receive(:parse).and_raise(Configuration::ParseError)
18
+ end
19
+
20
+ it "raises a SystemExit" do
21
+ expect { run }.to raise_error(SystemExit)
22
+ end
23
+
24
+ it "prints the error to the console" do
25
+ begin
26
+ run
27
+ rescue SystemExit
28
+ end
29
+ expect(stderr.string).to match(/There was an error reading your configuration file/)
22
30
  end
23
- CLI.new(double, double, double, ["http://foo.com", "--", "--tags", "~@wip"]).call(runner)
24
31
  end
25
32
  end
26
33
  end
@@ -9,66 +9,41 @@ module BBC::A11y
9
9
  end
10
10
 
11
11
  it "allows you to specify multiple pages" do
12
- BBC::A11y.configure do
12
+ configuration = BBC::A11y.configure do
13
13
  page "one.html"
14
14
  page "two.html"
15
15
  end
16
16
 
17
- expect(BBC::A11y.configuration.pages.length).to eq 2
18
- expect(BBC::A11y.configuration.pages[0].url).to eq "one.html"
19
- expect(BBC::A11y.configuration.pages[1].url).to eq "two.html"
20
- end
21
-
22
- it "allows you to specify scenarios to be skipped for a given page (using regexp)" do
23
- BBC::A11y.configure do
24
- page "three.html" do
25
- skip_scenario /javascript/
26
- end
27
- end
28
-
29
- page_settings = BBC::A11y.configuration.pages[0]
30
- test_case = double(name: "View the page with javascript disabled")
31
- expect(page_settings.skip_test_case?(test_case)).to be_truthy
32
- end
33
-
34
- it "allows you to specify scenarios to be skipped for a given page (using string)" do
35
- BBC::A11y.configure do
36
- page "three.html" do
37
- skip_scenario "javascript"
38
- end
39
- end
40
-
41
- page_settings = BBC::A11y.configuration.pages[0]
42
- test_case = double(name: "View the page with javascript disabled")
43
- expect(page_settings.skip_test_case?(test_case)).to be_truthy
17
+ expect(configuration.pages.length).to eq 2
18
+ expect(configuration.pages[0].url).to eq "one.html"
19
+ expect(configuration.pages[1].url).to eq "two.html"
44
20
  end
45
21
 
46
22
  it "allows you to specify settings for all pages matching a given URL pattern" do
47
- BBC::A11y.configure do
23
+ configuration = BBC::A11y.configure do
48
24
  page "three.html" do
49
- skip_scenario /^foo/
25
+ skip_standard /^Foo/
50
26
  end
51
27
  page "four.html"
52
28
  page "five.html"
53
29
 
54
30
  for_pages_matching /^f/ do
55
- skip_scenario /^bar/
31
+ skip_standard /^Bar/
56
32
  end
57
33
 
58
34
  for_pages_matching /^five/ do
59
- skip_scenario /^baz/
35
+ skip_standard /^Baz/
60
36
  end
61
37
  end
62
38
 
63
- bar = double(name: "bar_page.html")
64
- baz = double(name: "baz_page.html")
65
- four_page_settings = BBC::A11y.configuration.pages[1]
66
- expect(four_page_settings.skip_test_case?(bar)).to be_truthy
67
- five_page_settings = BBC::A11y.configuration.pages[2]
68
- expect(five_page_settings.skip_test_case?(bar)).to be_truthy
69
- expect(five_page_settings.skip_test_case?(baz)).to be_truthy
39
+ bar = double(name: "BarStandard")
40
+ baz = double(name: "BazStandard")
41
+ four_page_settings = configuration.pages[1]
42
+ expect(four_page_settings.skip_standard?(bar)).to be_truthy
43
+ five_page_settings = configuration.pages[2]
44
+ expect(five_page_settings.skip_standard?(bar)).to be_truthy
45
+ expect(five_page_settings.skip_standard?(baz)).to be_truthy
70
46
  end
71
47
 
72
48
  end
73
49
  end
74
-
@@ -1,7 +1,6 @@
1
1
  require 'capybara'
2
2
  require 'capybara/dsl'
3
- require 'capybara/poltergeist'
4
-
3
+ require 'phantomjs/poltergeist'
5
4
 
6
5
  Capybara.default_driver = :poltergeist
7
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbc-a11y
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Wynne
@@ -9,36 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-04 00:00:00.000000000 Z
12
+ date: 2015-12-09 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: cucumber
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: 2.0.0.rc
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: 2.0.0.rc
28
- - !ruby/object:Gem::Dependency
29
- name: rspec
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '3.0'
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '3.0'
42
14
  - !ruby/object:Gem::Dependency
43
15
  name: capybara
44
16
  requirement: !ruby/object:Gem::Requirement
@@ -54,21 +26,7 @@ dependencies:
54
26
  - !ruby/object:Gem::Version
55
27
  version: '0'
56
28
  - !ruby/object:Gem::Dependency
57
- name: poltergeist
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: w3c_validators
29
+ name: colorize
72
30
  requirement: !ruby/object:Gem::Requirement
73
31
  requirements:
74
32
  - - ">="
@@ -82,27 +40,27 @@ dependencies:
82
40
  - !ruby/object:Gem::Version
83
41
  version: '0'
84
42
  - !ruby/object:Gem::Dependency
85
- name: cld
43
+ name: rspec
86
44
  requirement: !ruby/object:Gem::Requirement
87
45
  requirements:
88
- - - ">="
46
+ - - "~>"
89
47
  - !ruby/object:Gem::Version
90
- version: '0'
91
- type: :runtime
48
+ version: '3.0'
49
+ type: :development
92
50
  prerelease: false
93
51
  version_requirements: !ruby/object:Gem::Requirement
94
52
  requirements:
95
- - - ">="
53
+ - - "~>"
96
54
  - !ruby/object:Gem::Version
97
- version: '0'
55
+ version: '3.0'
98
56
  - !ruby/object:Gem::Dependency
99
- name: colorize
57
+ name: aruba
100
58
  requirement: !ruby/object:Gem::Requirement
101
59
  requirements:
102
60
  - - ">="
103
61
  - !ruby/object:Gem::Version
104
62
  version: '0'
105
- type: :runtime
63
+ type: :development
106
64
  prerelease: false
107
65
  version_requirements: !ruby/object:Gem::Requirement
108
66
  requirements:
@@ -110,7 +68,7 @@ dependencies:
110
68
  - !ruby/object:Gem::Version
111
69
  version: '0'
112
70
  - !ruby/object:Gem::Dependency
113
- name: aruba
71
+ name: pry
114
72
  requirement: !ruby/object:Gem::Requirement
115
73
  requirements:
116
74
  - - ">="
@@ -124,7 +82,7 @@ dependencies:
124
82
  - !ruby/object:Gem::Version
125
83
  version: '0'
126
84
  - !ruby/object:Gem::Dependency
127
- name: pry
85
+ name: rake
128
86
  requirement: !ruby/object:Gem::Requirement
129
87
  requirements:
130
88
  - - ">="
@@ -138,7 +96,7 @@ dependencies:
138
96
  - !ruby/object:Gem::Version
139
97
  version: '0'
140
98
  - !ruby/object:Gem::Dependency
141
- name: rake
99
+ name: cucumber
142
100
  requirement: !ruby/object:Gem::Requirement
143
101
  requirements:
144
102
  - - ">="
@@ -160,11 +118,13 @@ extensions: []
160
118
  extra_rdoc_files: []
161
119
  files:
162
120
  - ".rspec"
121
+ - ".ruby-version"
163
122
  - CONTRIBUTING.md
164
123
  - Gemfile
165
124
  - LICENSE
166
125
  - README.md
167
126
  - Rakefile
127
+ - a11y.rb
168
128
  - bbc-a11y.gemspec
169
129
  - bin/a11y
170
130
  - examples/bbc-pages/Gemfile
@@ -178,32 +138,44 @@ files:
178
138
  - examples/local-web-app/public/perfect.html
179
139
  - examples/local-web-app/readme.md
180
140
  - features/README.md
181
- - features/exit_status.feature
182
- - features/specify_url_via_cli.feature
183
- - features/specify_url_via_config.feature
141
+ - features/check_standards/focusable_controls.feature
142
+ - features/check_standards/form_interactions.feature
143
+ - features/check_standards/form_labels.feature
144
+ - features/check_standards/headings.feature
145
+ - features/check_standards/image_alt.feature
146
+ - features/check_standards/language.feature
147
+ - features/check_standards/main_landmark.feature
148
+ - features/check_standards/tab_index.feature
149
+ - features/cli/display_failing_result.feature
150
+ - features/cli/exit_status.feature
151
+ - features/cli/provide_muting_tips.feature
152
+ - features/cli/report_configuration_errors.feature
153
+ - features/cli/skipping_standards.feature
154
+ - features/cli/specify_url.feature
155
+ - features/cli/specify_url_via_config.feature
156
+ - features/mute_errors.feature
184
157
  - features/step_definitions/steps.rb
185
158
  - features/support/env.rb
186
159
  - features/support/web_server.rb
187
160
  - features/support/web_server/missing_header.html
188
161
  - features/support/web_server/perfect.html
189
- - lib/bbc/a11y.rb
190
162
  - lib/bbc/a11y/cli.rb
191
163
  - lib/bbc/a11y/configuration.rb
192
- - lib/bbc/a11y/cucumber_runner.rb
193
- - lib/bbc/a11y/cucumber_support.rb
194
- - lib/bbc/a11y/cucumber_support/disabled_w3c.rb
195
- - lib/bbc/a11y/cucumber_support/heading_hierarchy.rb
196
- - lib/bbc/a11y/cucumber_support/language_detector.rb
197
- - lib/bbc/a11y/cucumber_support/matchers.rb
198
- - lib/bbc/a11y/cucumber_support/page.rb
199
- - lib/bbc/a11y/cucumber_support/per_page_checks.rb
200
- - lib/bbc/a11y/cucumber_support/w3c.rb
164
+ - lib/bbc/a11y/linter.rb
165
+ - lib/bbc/a11y/standards.rb
166
+ - lib/bbc/a11y/standards/anchor_hrefs.rb
167
+ - lib/bbc/a11y/standards/content_follows_headings.rb
168
+ - lib/bbc/a11y/standards/exactly_one_main_heading.rb
169
+ - lib/bbc/a11y/standards/exactly_one_main_landmark.rb
170
+ - lib/bbc/a11y/standards/form_labels.rb
171
+ - lib/bbc/a11y/standards/form_submit_buttons.rb
172
+ - lib/bbc/a11y/standards/heading_hierarchy.rb
173
+ - lib/bbc/a11y/standards/image_alt.rb
174
+ - lib/bbc/a11y/standards/language_attribute.rb
175
+ - lib/bbc/a11y/standards/tab_index.rb
201
176
  - lib/bbc/a11y/version
202
177
  - spec/bbc/a11y/cli_spec.rb
203
178
  - spec/bbc/a11y/configuration_spec.rb
204
- - spec/bbc/a11y/cucumber_support/heading_hierarchy_spec.rb
205
- - spec/bbc/a11y/cucumber_support/matchers_spec.rb
206
- - spec/bbc/a11y/cucumber_support/page_spec.rb
207
179
  - standards/01_core-purpose.md
208
180
  - standards/02_validation.feature
209
181
  - standards/03_javascript.feature
@@ -255,15 +227,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
227
  version: '0'
256
228
  requirements: []
257
229
  rubyforge_project:
258
- rubygems_version: 2.2.2
230
+ rubygems_version: 2.4.5.1
259
231
  signing_key:
260
232
  specification_version: 4
261
- summary: bbc-a11y-0.0.12
233
+ summary: bbc-a11y-0.0.13
262
234
  test_files:
263
235
  - features/README.md
264
- - features/exit_status.feature
265
- - features/specify_url_via_cli.feature
266
- - features/specify_url_via_config.feature
236
+ - features/check_standards/focusable_controls.feature
237
+ - features/check_standards/form_interactions.feature
238
+ - features/check_standards/form_labels.feature
239
+ - features/check_standards/headings.feature
240
+ - features/check_standards/image_alt.feature
241
+ - features/check_standards/language.feature
242
+ - features/check_standards/main_landmark.feature
243
+ - features/check_standards/tab_index.feature
244
+ - features/cli/display_failing_result.feature
245
+ - features/cli/exit_status.feature
246
+ - features/cli/provide_muting_tips.feature
247
+ - features/cli/report_configuration_errors.feature
248
+ - features/cli/skipping_standards.feature
249
+ - features/cli/specify_url.feature
250
+ - features/cli/specify_url_via_config.feature
251
+ - features/mute_errors.feature
267
252
  - features/step_definitions/steps.rb
268
253
  - features/support/env.rb
269
254
  - features/support/web_server.rb
@@ -271,7 +256,3 @@ test_files:
271
256
  - features/support/web_server/perfect.html
272
257
  - spec/bbc/a11y/cli_spec.rb
273
258
  - spec/bbc/a11y/configuration_spec.rb
274
- - spec/bbc/a11y/cucumber_support/heading_hierarchy_spec.rb
275
- - spec/bbc/a11y/cucumber_support/matchers_spec.rb
276
- - spec/bbc/a11y/cucumber_support/page_spec.rb
277
- has_rdoc: