bbc-a11y 0.0.2

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 (59) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +1 -0
  3. data/CONTRIBUTING.md +19 -0
  4. data/Gemfile +2 -0
  5. data/LICENSE +21 -0
  6. data/README.md +54 -0
  7. data/Rakefile +12 -0
  8. data/bbc-a11y.gemspec +32 -0
  9. data/bin/a11y +5 -0
  10. data/example/.a11y.rb +64 -0
  11. data/example/Gemfile +4 -0
  12. data/example/Rakefile +3 -0
  13. data/example/config.ru +1 -0
  14. data/example/public/missing_header.html +13 -0
  15. data/example/public/perfect.html +14 -0
  16. data/example/readme.md +0 -0
  17. data/features/01_core-purpose.md +24 -0
  18. data/features/02_validation.feature +31 -0
  19. data/features/03_javascript.feature +40 -0
  20. data/features/04_language.feature +58 -0
  21. data/features/05_page_title.feature +45 -0
  22. data/features/06_main_landmark.feature +24 -0
  23. data/features/07_headings.feature +65 -0
  24. data/features/08_title_attribute.feature +71 -0
  25. data/features/09_tabindex.feature +38 -0
  26. data/features/10_form-labels.md +47 -0
  27. data/features/11_visible-on-focus.md +58 -0
  28. data/features/13_colour-contrast.md +27 -0
  29. data/features/14_colour-meaning.md +19 -0
  30. data/features/15_focusable-controls.md +45 -0
  31. data/features/16_table.md +109 -0
  32. data/features/17_control-styles.md +78 -0
  33. data/features/18_focus-styles.md +36 -0
  34. data/features/19_form-interactions.md +33 -0
  35. data/features/20_image-alt.md +34 -0
  36. data/features/21_min-font-sizes.md +64 -0
  37. data/features/22_resize-zoom.md +80 -0
  38. data/features/step_definitions/core_content_steps.rb +3 -0
  39. data/features/step_definitions/language_steps.rb +21 -0
  40. data/features/step_definitions/page_steps.rb +46 -0
  41. data/features/step_definitions/w3c_steps.rb +7 -0
  42. data/features/support/capybara.rb +38 -0
  43. data/features/support/skipper.rb +5 -0
  44. data/features/support/world.rb +3 -0
  45. data/features/support/world_extender.rb +5 -0
  46. data/lib/bbc/a11y/cli.rb +49 -0
  47. data/lib/bbc/a11y/configuration.rb +83 -0
  48. data/lib/bbc/a11y/cucumber_runner.rb +133 -0
  49. data/lib/bbc/a11y/cucumber_support/heading_hierarchy.rb +92 -0
  50. data/lib/bbc/a11y/cucumber_support/language_detector.rb +26 -0
  51. data/lib/bbc/a11y/cucumber_support/page.rb +81 -0
  52. data/lib/bbc/a11y/cucumber_support/per_page_checks.rb +28 -0
  53. data/lib/bbc/a11y/cucumber_support/w3c.rb +36 -0
  54. data/lib/bbc/a11y/cucumber_support.rb +49 -0
  55. data/lib/bbc/a11y/version +1 -0
  56. data/lib/bbc/a11y.rb +4 -0
  57. data/spec/bbc/a11y/cucumber_support/heading_hierarchy_spec.rb +123 -0
  58. data/spec/bbc/a11y/cucumber_support/page_spec.rb +130 -0
  59. metadata +274 -0
@@ -0,0 +1,49 @@
1
+ require 'bbc/a11y/cucumber_support/language_detector'
2
+ require 'bbc/a11y/cucumber_support/page'
3
+ require 'bbc/a11y/cucumber_support/w3c'
4
+ require 'bbc/a11y/cucumber_support/per_page_checks'
5
+
6
+ module BBC
7
+ module A11y
8
+
9
+ # These are the methods available to step definitions
10
+ # that test the specifications.
11
+ module CucumberSupport
12
+ include PerPageChecks
13
+
14
+ class << self
15
+ attr_accessor :current_page_settings
16
+ end
17
+
18
+ # Returns an object that can validate URLs
19
+ def w3c
20
+ @w3c ||= W3C.new
21
+ end
22
+
23
+ # An object that represents the current page being viewed in the browser
24
+ def page
25
+ @page ||= Page.new(browser)
26
+ end
27
+
28
+ # An object to detect the natural lanugage of the page
29
+ def language
30
+ @language ||= LanguageDetector.new
31
+ end
32
+
33
+ # Settings specified for this test run
34
+ def settings
35
+ CucumberSupport.current_page_settings
36
+ end
37
+
38
+ # Ask for a manual check
39
+ def confirm(question)
40
+ formatted_question = "\n #{question} [Y/n]"
41
+ answer = ask(formatted_question).strip
42
+ fail unless ["Y", "y", ""].include?(answer)
43
+ end
44
+
45
+ end
46
+ end
47
+
48
+ end
49
+
@@ -0,0 +1 @@
1
+ 0.0.2
data/lib/bbc/a11y.rb ADDED
@@ -0,0 +1,4 @@
1
+ module BBC
2
+ module A11y
3
+ end
4
+ end
@@ -0,0 +1,123 @@
1
+ require 'bbc/a11y/cucumber_support/heading_hierarchy'
2
+ require 'capybara'
3
+
4
+ module BBC::A11y::CucumberSupport
5
+ describe HeadingHierarchy do
6
+
7
+ let(:hierarchy) do
8
+ HeadingHierarchy.new(page)
9
+ end
10
+
11
+ let(:page) do
12
+ # patch Capybara::String to look just enough like a real Capybara::Session to work
13
+ page = Capybara.string(html)
14
+ source = html
15
+ page.define_singleton_method(:source) { source }
16
+ page
17
+ end
18
+
19
+ describe '#validate' do
20
+
21
+ context 'a simple, valid h1-h6 hierachy' do
22
+ let(:html) { <<-HTML }
23
+ <html>
24
+ <body>
25
+ <h1>Heading 1</h1>
26
+ <h2>Heading 2</h2>
27
+ <h3>Heading 3</h3>
28
+ <h4>Heading 4</h4>
29
+ <h5>Heading 5</h5>
30
+ <h6>Heading 6</h6>
31
+ </body>
32
+ </html>
33
+ HTML
34
+
35
+ it 'passes' do
36
+ expect { hierarchy.validate }.not_to raise_error
37
+ end
38
+ end
39
+
40
+ context 'an invalid h1-h3 hierarchy' do
41
+ let(:html) { <<-HTML }
42
+ <html>
43
+ <body>
44
+ <h1>Heading 1</h1>
45
+ <h3>Heading 3</h3>
46
+ <h2>Heading 2</h2>
47
+ </body>
48
+ </html>
49
+ HTML
50
+
51
+ it 'fails' do
52
+ expect { hierarchy.validate }.to raise_error("Headings were not in order: h1, **h3**, h2")
53
+ end
54
+ end
55
+
56
+ context 'an hierarchy that skips back up from h4 to h2' do
57
+ let(:html) { <<-HTML }
58
+ <html>
59
+ <body>
60
+ <h1>Heading 1</h1>
61
+ <h2>Heading 2</h2>
62
+ <h3>Heading 3</h3>
63
+ <h4>Heading 4</h4>
64
+ <h2>Heading 2b</h2>
65
+ <h3>Heading 3b</h3>
66
+ </body>
67
+ </html>
68
+ HTML
69
+
70
+ it 'passes' do
71
+ expect { hierarchy.validate }.not_to raise_error
72
+ end
73
+ end
74
+
75
+
76
+ end
77
+
78
+ describe "#to_s" do
79
+ context 'an hierarchy that skips back up from h4 to h2' do
80
+ let(:html) { <<-HTML }
81
+ <html>
82
+ <body>
83
+ <h1>Heading 1</h1>
84
+ <h2>Heading 2</h2>
85
+ <h3>Heading 3</h3>
86
+ <h4>Heading 4</h4>
87
+ <h2>Heading 2b</h2>
88
+ <h3>Heading 3b</h3>
89
+ </body>
90
+ </html>
91
+ HTML
92
+
93
+ it 'renders a nested hierarchy' do
94
+ expected = <<-TEXT
95
+ h1
96
+ h2
97
+ h3
98
+ h4
99
+ h2
100
+ h3
101
+ TEXT
102
+ expect( hierarchy.to_s ).to eq expected.strip
103
+ end
104
+ end
105
+ end
106
+
107
+ context "hidden headings" do
108
+ let(:html) { <<-HTML }
109
+ <html>
110
+ <body>
111
+ <h1 style="display:none">Heading 1</h1>
112
+ </body>
113
+ </html>
114
+ HTML
115
+
116
+ it "sees them" do
117
+ expect( hierarchy.to_s ).to eq "h1"
118
+ end
119
+
120
+ end
121
+
122
+ end
123
+ end
@@ -0,0 +1,130 @@
1
+ require 'bbc/a11y/cucumber_support/page'
2
+ require 'capybara'
3
+
4
+ module BBC::A11y::CucumberSupport
5
+ describe Page do
6
+ let(:page) do
7
+ Page.new(Capybara.string(html))
8
+ end
9
+
10
+ describe '#must_have_lang_attribute' do
11
+ context 'with no lang attribute' do
12
+ let(:html) { <<-HTML }
13
+ <html>
14
+ </html>
15
+ HTML
16
+
17
+ it 'fails' do
18
+ expect { page.must_have_lang_attribute }.to raise_error(
19
+ RSpec::Expectations::ExpectationNotMetError,
20
+ %{expected to find css "html[lang]" but there were no matches})
21
+ end
22
+ end
23
+
24
+ context 'with a lang attribute' do
25
+ let(:html) { <<-HTML }
26
+ <html lang="en-GB">
27
+ </html>
28
+ HTML
29
+
30
+ it 'passes' do
31
+ expect { page.must_have_lang_attribute }.not_to raise_error
32
+ end
33
+ end
34
+ end
35
+
36
+ describe '#must_have_lang_attribute_of' do
37
+ let(:html) { <<-HTML }
38
+ <html lang="en-GB">
39
+ </html>
40
+ HTML
41
+
42
+ it 'passes for a matching lang attribute' do
43
+ expect { page.must_have_lang_attribute_of('en') }.not_to raise_error
44
+ end
45
+
46
+ it 'fails for the wrong language code' do
47
+ expect { page.must_have_lang_attribute_of('fr') }.to raise_error(RSpec::Expectations::ExpectationNotMetError)
48
+ end
49
+ end
50
+
51
+ describe "#must_have_no_elements_with_title_attribute_content_repeated_within" do
52
+ context "when an element has the same title attribute as its contents" do
53
+ let(:html) { <<-HTML }
54
+ <html>
55
+ <body>
56
+ <a title="News">News</a>
57
+ </body>
58
+ </html>
59
+ HTML
60
+
61
+ it "fails" do
62
+ expect { page.must_have_no_elements_with_title_attribute_content_repeated_within }.
63
+ to raise_error(RSpec::Expectations::ExpectationNotMetError)
64
+ end
65
+ end
66
+
67
+ context "when an element has a valid title" do
68
+ let(:html) { <<-HTML }
69
+ <html>
70
+ <body>
71
+ <img title="A picture of a cat">
72
+ </body>
73
+ </html>
74
+ HTML
75
+
76
+ it "passes" do
77
+ expect { page.must_have_no_elements_with_title_attribute_content_repeated_within }.
78
+ not_to raise_error
79
+ end
80
+ end
81
+
82
+ end
83
+
84
+ describe "#must_have_no_form_fields_with_label_and_title" do
85
+ context "a form field with both label and title" do
86
+ let(:html) { <<-HTML }
87
+ <html>
88
+ <body>
89
+ <form>
90
+ <label for="name">Your name</label>
91
+ <input id="name" title="Your name please">
92
+ </form>
93
+ </body>
94
+ </html>
95
+ HTML
96
+
97
+ it "fails" do
98
+ expect { page.must_have_no_form_fields_with_label_and_title }.
99
+ to raise_error(RSpec::Expectations::ExpectationNotMetError)
100
+ end
101
+ end
102
+ end
103
+
104
+ describe "#must_not_have_any_positive_tabindex_values" do
105
+ context "a positive tabindex value" do
106
+ let(:html) { <<-HTML }
107
+ <html>
108
+ <body>
109
+ <a tabindex="1">Important</a>
110
+ </body>
111
+ </html>
112
+ HTML
113
+
114
+ it "fails" do
115
+ expect { page.must_not_have_any_positive_tabindex_values }.
116
+ to raise_error(RSpec::Expectations::ExpectationNotMetError)
117
+ end
118
+ end
119
+ end
120
+
121
+ describe '#to_s' do
122
+ let(:html) { "<html><body><h1>Header</h1><p>More stuff</p></body></html>" }
123
+
124
+ it 'renders the visible text on the page' do
125
+ expect(page.to_s).to eq "HeaderMore stuff"
126
+ end
127
+ end
128
+
129
+ end
130
+ end
metadata ADDED
@@ -0,0 +1,274 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bbc-a11y
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Matt Wynne
8
+ - Ian Pouncey
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-02-12 00:00:00.000000000 Z
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
+ - !ruby/object:Gem::Dependency
43
+ name: capybara
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: selenium-webdriver
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
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: cld
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: colorize
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: aruba
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: pry
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: rake
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ description: A tool for testing the compliance of web URLs against the BBC's accessibilty
155
+ guidelines
156
+ email: github@ipouncey.co.uk
157
+ executables: []
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - ".rspec"
162
+ - CONTRIBUTING.md
163
+ - Gemfile
164
+ - LICENSE
165
+ - README.md
166
+ - Rakefile
167
+ - bbc-a11y.gemspec
168
+ - bin/a11y
169
+ - example/.a11y.rb
170
+ - example/Gemfile
171
+ - example/Rakefile
172
+ - example/config.ru
173
+ - example/public/missing_header.html
174
+ - example/public/perfect.html
175
+ - example/readme.md
176
+ - features/01_core-purpose.md
177
+ - features/02_validation.feature
178
+ - features/03_javascript.feature
179
+ - features/04_language.feature
180
+ - features/05_page_title.feature
181
+ - features/06_main_landmark.feature
182
+ - features/07_headings.feature
183
+ - features/08_title_attribute.feature
184
+ - features/09_tabindex.feature
185
+ - features/10_form-labels.md
186
+ - features/11_visible-on-focus.md
187
+ - features/13_colour-contrast.md
188
+ - features/14_colour-meaning.md
189
+ - features/15_focusable-controls.md
190
+ - features/16_table.md
191
+ - features/17_control-styles.md
192
+ - features/18_focus-styles.md
193
+ - features/19_form-interactions.md
194
+ - features/20_image-alt.md
195
+ - features/21_min-font-sizes.md
196
+ - features/22_resize-zoom.md
197
+ - features/step_definitions/core_content_steps.rb
198
+ - features/step_definitions/language_steps.rb
199
+ - features/step_definitions/page_steps.rb
200
+ - features/step_definitions/w3c_steps.rb
201
+ - features/support/capybara.rb
202
+ - features/support/skipper.rb
203
+ - features/support/world.rb
204
+ - features/support/world_extender.rb
205
+ - lib/bbc/a11y.rb
206
+ - lib/bbc/a11y/cli.rb
207
+ - lib/bbc/a11y/configuration.rb
208
+ - lib/bbc/a11y/cucumber_runner.rb
209
+ - lib/bbc/a11y/cucumber_support.rb
210
+ - lib/bbc/a11y/cucumber_support/heading_hierarchy.rb
211
+ - lib/bbc/a11y/cucumber_support/language_detector.rb
212
+ - lib/bbc/a11y/cucumber_support/page.rb
213
+ - lib/bbc/a11y/cucumber_support/per_page_checks.rb
214
+ - lib/bbc/a11y/cucumber_support/w3c.rb
215
+ - lib/bbc/a11y/version
216
+ - spec/bbc/a11y/cucumber_support/heading_hierarchy_spec.rb
217
+ - spec/bbc/a11y/cucumber_support/page_spec.rb
218
+ homepage: https://cucumber.pro
219
+ licenses:
220
+ - MIT
221
+ metadata: {}
222
+ post_install_message:
223
+ rdoc_options:
224
+ - "--charset=UTF-8"
225
+ require_paths:
226
+ - lib
227
+ required_ruby_version: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - ">="
230
+ - !ruby/object:Gem::Version
231
+ version: 1.9.3
232
+ required_rubygems_version: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ requirements: []
238
+ rubyforge_project:
239
+ rubygems_version: 2.4.5
240
+ signing_key:
241
+ specification_version: 4
242
+ summary: bbc-a11y-0.0.2
243
+ test_files:
244
+ - features/01_core-purpose.md
245
+ - features/02_validation.feature
246
+ - features/03_javascript.feature
247
+ - features/04_language.feature
248
+ - features/05_page_title.feature
249
+ - features/06_main_landmark.feature
250
+ - features/07_headings.feature
251
+ - features/08_title_attribute.feature
252
+ - features/09_tabindex.feature
253
+ - features/10_form-labels.md
254
+ - features/11_visible-on-focus.md
255
+ - features/13_colour-contrast.md
256
+ - features/14_colour-meaning.md
257
+ - features/15_focusable-controls.md
258
+ - features/16_table.md
259
+ - features/17_control-styles.md
260
+ - features/18_focus-styles.md
261
+ - features/19_form-interactions.md
262
+ - features/20_image-alt.md
263
+ - features/21_min-font-sizes.md
264
+ - features/22_resize-zoom.md
265
+ - features/step_definitions/core_content_steps.rb
266
+ - features/step_definitions/language_steps.rb
267
+ - features/step_definitions/page_steps.rb
268
+ - features/step_definitions/w3c_steps.rb
269
+ - features/support/capybara.rb
270
+ - features/support/skipper.rb
271
+ - features/support/world.rb
272
+ - features/support/world_extender.rb
273
+ - spec/bbc/a11y/cucumber_support/heading_hierarchy_spec.rb
274
+ - spec/bbc/a11y/cucumber_support/page_spec.rb