bbc-a11y 0.0.16 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/bbc-a11y.gemspec +2 -0
  3. data/circle.yml +3 -0
  4. data/features/check_standards/focusable_controls.feature +2 -2
  5. data/features/check_standards/form_interactions.feature +3 -4
  6. data/features/check_standards/form_labels.feature +4 -4
  7. data/features/check_standards/headings.feature +17 -16
  8. data/features/check_standards/image_alt.feature +3 -3
  9. data/features/check_standards/language.feature +3 -3
  10. data/features/check_standards/main_landmark.feature +5 -5
  11. data/features/check_standards/minimum_text_size.feature +36 -0
  12. data/features/check_standards/tab_index.feature +4 -4
  13. data/features/check_standards/title_attribute.feature +3 -3
  14. data/features/cli/coloured_output.feature +15 -0
  15. data/features/cli/display_failing_result.feature +1 -1
  16. data/features/cli/display_result_summary.feature +2 -2
  17. data/features/cli/missing_config_file_warning.feature +10 -0
  18. data/features/cli/skipping_standards.feature +1 -1
  19. data/features/mute_errors.feature +3 -3
  20. data/features/step_definitions/steps.rb +38 -6
  21. data/features/support/browserify.rb +3 -0
  22. data/features/support/capybara.rb +49 -0
  23. data/features/support/web_server.rb +14 -3
  24. data/karma.conf.js +57 -0
  25. data/lib/bbc/a11y/cli.rb +37 -6
  26. data/lib/bbc/a11y/configuration.rb +10 -0
  27. data/lib/bbc/a11y/javascript.rb +13 -0
  28. data/lib/bbc/a11y/js/a11y.js +10 -0
  29. data/lib/bbc/a11y/js/standards.js +80 -0
  30. data/lib/bbc/a11y/js/standards/anchorsMustHaveHrefs.js +9 -0
  31. data/lib/bbc/a11y/js/standards/contentMustFollowHeadings.js +15 -0
  32. data/lib/bbc/a11y/js/standards/elementsWithZeroTabIndexMustBeFields.js +10 -0
  33. data/lib/bbc/a11y/js/standards/exactlyOneMainHeading.js +13 -0
  34. data/lib/bbc/a11y/js/standards/exactlyOneMainLandmark.js +13 -0
  35. data/lib/bbc/a11y/js/standards/fieldsMustHaveLabelsOrTitles.js +26 -0
  36. data/lib/bbc/a11y/js/standards/formsMustHaveSubmitButtons.js +12 -0
  37. data/lib/bbc/a11y/js/standards/headingsMustBeInAscendingOrder.js +31 -0
  38. data/lib/bbc/a11y/js/standards/htmlMustHaveLangAttribute.js +9 -0
  39. data/lib/bbc/a11y/js/standards/imagesMustHaveAltAttributes.js +9 -0
  40. data/lib/bbc/a11y/js/standards/minimumTextSize.js +25 -0
  41. data/lib/bbc/a11y/js/standards/titleAttributesOnlyOnInputs.js +9 -0
  42. data/lib/bbc/a11y/js/xpath.js +45 -0
  43. data/lib/bbc/a11y/linter.rb +20 -11
  44. data/lib/bbc/a11y/runner.rb +13 -7
  45. data/lib/bbc/a11y/standards/exactly_one_main_heading.rb +8 -3
  46. data/lib/bbc/a11y/version +1 -1
  47. data/package.json +33 -0
  48. data/spec/bbc/a11y/js/a11ySpec.js +42 -0
  49. data/spec/bbc/a11y/js/standardsSpec.js +32 -0
  50. data/spec/bbc/a11y/js/xpathSpec.js +31 -0
  51. data/standards/support/capybara.rb +5 -1
  52. metadata +66 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8dd9e7e73e7a90b1f1a0151176196f940e149c8e
4
- data.tar.gz: f793efc23dc248e5c1261368ea5f5ec0c2ec3e16
3
+ metadata.gz: a03ce44ea3d9fc6824112a5764a70b34008e2391
4
+ data.tar.gz: baeaa81881cefee49c813497c0a946a8d8cc4768
5
5
  SHA512:
6
- metadata.gz: db950a702d499d56739b17087ee83b69ffd62c0548ee91e9b91d3dfa1e4d8dcfd740505dfcd708803be56690f2913e4994b008c516fefbd79dde54b80720a012
7
- data.tar.gz: 9c2706280a6e6767469c2af7c1fea8c6abb1d88288034b02dd4c34742e518eaa22aa3cef34255c2a9505a0349f0d39179d838de090a28e8ff458c8d4f5757535
6
+ metadata.gz: f0488992d7713f61ecf7a540f3c674808e4bcd87bb302ef9cd695f185dfec776beada3a00060e5ad49541fa1275dc478f9415277b77054b9a3811a717fd6d249
7
+ data.tar.gz: c0b23d60238dc0ca04091a4df5dacecf1cfc88a9d5e097177c1918840b44516f0846511dcdeec0507cace911996e60a7d57ea27426e46aea9e17ff15e54e91a3
@@ -14,6 +14,8 @@ Gem::Specification.new do |s|
14
14
  s.required_ruby_version = ">= 1.9.3"
15
15
 
16
16
  s.add_dependency 'capybara'
17
+ s.add_dependency 'phantomjs'
18
+ s.add_dependency 'poltergeist'
17
19
  s.add_dependency 'colorize'
18
20
 
19
21
  s.add_development_dependency 'rspec', '~> 3.0'
@@ -0,0 +1,3 @@
1
+ test:
2
+ override:
3
+ - bundle exec rake
@@ -42,7 +42,7 @@ Feature: Focusable Controls
42
42
  <li><a href="#entertainmenttab">Entertainment</a></li>
43
43
  </ul>
44
44
  """
45
- When I validate the anchor hrefs standards
45
+ When I validate the "anchors must have hrefs" standard
46
46
  Then it passes
47
47
 
48
48
  Scenario: Some anchor tags do not have href attributes
@@ -54,7 +54,7 @@ Feature: Focusable Controls
54
54
  <li><a>Entertainment</a></li>
55
55
  </ul>
56
56
  """
57
- When I validate the anchor hrefs standards
57
+ When I validate the "anchors must have hrefs" standard
58
58
  Then it fails with the message:
59
59
  """
60
60
  Anchor has no href attribute: /html/body/ul/li[1]/a
@@ -27,7 +27,7 @@ Feature: Form Interactions
27
27
  <input type="submit" value="Search">
28
28
  </form>
29
29
  """
30
- When I validate the form submit buttons standards
30
+ When I validate the "forms must have submit buttons" standard
31
31
  Then it passes
32
32
 
33
33
  Scenario: Form with no submit button
@@ -38,7 +38,7 @@ Feature: Form Interactions
38
38
  <input type="text" name="q" id="q">
39
39
  </form>
40
40
  """
41
- When I validate the form submit buttons standards
41
+ When I validate the "forms must have submit buttons" standard
42
42
  Then it fails with the message:
43
43
  """
44
44
  Form has no submit button: /html/body/form
@@ -52,6 +52,5 @@ Feature: Form Interactions
52
52
  <button type="submit">Search</button>
53
53
  </form>
54
54
  """
55
- When I validate the form submit buttons standards
55
+ When I validate the "forms must have submit buttons" standard
56
56
  Then it passes
57
-
@@ -29,7 +29,7 @@ Feature: Correctly use form labels
29
29
 
30
30
  <input type="text" name="q" title="Search the BBC" />
31
31
  """
32
- When I validate the form labels standards
32
+ When I validate the "fields must have labels or titles" standard
33
33
  Then it passes
34
34
 
35
35
  Scenario: Some fields without labels or title attributes
@@ -44,7 +44,7 @@ Feature: Correctly use form labels
44
44
  <input type="text" name="q" aria-label="Search the BBC" />
45
45
  <input type="text" name="q" placeholder="Search the BBC" />
46
46
  """
47
- When I validate the form labels standards
47
+ When I validate the "fields must have labels or titles" standard
48
48
  Then it fails with the message:
49
49
  """
50
50
  Field has no label or title attribute: /html/body/textarea
@@ -60,5 +60,5 @@ Feature: Correctly use form labels
60
60
  """
61
61
  <input type=hidden name=a value=b>
62
62
  """
63
- When I validate the form labels standards
64
- Then it passes
63
+ When I validate the "fields must have labels or titles" standard
64
+ Then it passes
@@ -23,10 +23,10 @@ Feature: Headings
23
23
  """
24
24
  <h2>Heading 2</h2>
25
25
  """
26
- When I validate the heading standards
26
+ When I validate the "exactly one main heading" standard
27
27
  Then it fails with the message:
28
28
  """
29
- A document must have exactly one main heading. Found 0 h1 elements.
29
+ Found 0 h1 elements.
30
30
  """
31
31
 
32
32
  Scenario: More than one main heading
@@ -36,10 +36,10 @@ Feature: Headings
36
36
  <h2>Heading 2</h2>
37
37
  <h1>Heading 1</h1>
38
38
  """
39
- When I validate the heading standards
39
+ When I validate the "exactly one main heading" standard
40
40
  Then it fails with the message:
41
41
  """
42
- A document must have exactly one main heading. Found 2 h1 elements.
42
+ Found 2 h1 elements: /html/body/h1[1] /html/body/h1[2]
43
43
  """
44
44
 
45
45
  Scenario: Headings in ascending order
@@ -52,7 +52,7 @@ Feature: Headings
52
52
  <h5>Heading 5</h5>
53
53
  <h6>Heading 6</h6>
54
54
  """
55
- When I validate the heading standards
55
+ When I validate the "headings must be in ascending order" standard
56
56
  Then it passes
57
57
 
58
58
  Scenario: Headings in invalid order
@@ -62,10 +62,10 @@ Feature: Headings
62
62
  <h3>Heading 3</h3>
63
63
  <h2>Heading 2</h2>
64
64
  """
65
- When I validate the heading standards
65
+ When I validate the "headings must be in ascending order" standard
66
66
  Then it fails with the message:
67
67
  """
68
- Headings are not in order: h1 is followed by h3
68
+ Headings are not in order: /html/body/h1 /html/body/h3
69
69
  """
70
70
 
71
71
  Scenario: Headings jump back up more than one level
@@ -78,7 +78,7 @@ Feature: Headings
78
78
  <h2>Heading 2b</h2>
79
79
  <h3>Heading 3b</h3>
80
80
  """
81
- When I validate the heading standards
81
+ When I validate the "headings must be in ascending order" standard
82
82
  Then it passes
83
83
 
84
84
  Scenario: Heading is hidden
@@ -88,10 +88,10 @@ Feature: Headings
88
88
  <h3 style="display:none">Heading 3</h3>
89
89
  <h2>Heading 2</h2>
90
90
  """
91
- When I validate the heading standards
91
+ When I validate the "headings must be in ascending order" standard
92
92
  Then it fails with the message:
93
93
  """
94
- Headings are not in order: h1 is followed by h3
94
+ Headings are not in order: /html/body/h1 /html/body/h3
95
95
  """
96
96
 
97
97
  Scenario: Heading in a script tag
@@ -103,7 +103,7 @@ Feature: Headings
103
103
  </script>
104
104
  <h2>Heading 2</h2>
105
105
  """
106
- When I validate the heading standards
106
+ When I validate the "headings must be in ascending order" standard
107
107
  Then it passes
108
108
 
109
109
  Scenario: Subheading before the first main heading
@@ -113,7 +113,7 @@ Feature: Headings
113
113
  <h1>Heading 1</h1>
114
114
  <h2>Heading 2</h2>
115
115
  """
116
- When I validate the heading standards
116
+ When I validate the "headings must be in ascending order" standard
117
117
  Then it passes
118
118
 
119
119
  Scenario: Content between headings
@@ -125,13 +125,14 @@ Feature: Headings
125
125
  <h2>Another heading</h2>
126
126
  <p>non-heading content</p>
127
127
  <h3>Main content</h3>
128
+ non-heading content
128
129
  <h2>Secondary content</h2>
129
130
  <p>non-heading content</p>
130
131
  <h2>Tertiary content</h2>
131
- <p>Lorem ipsum…</p>
132
+ non-heading content
132
133
  </div>
133
134
  """
134
- When I validate the heading standards
135
+ When I validate the "content must follow headings" standard
135
136
  Then it passes
136
137
 
137
138
  Scenario: No content between headings
@@ -145,8 +146,8 @@ Feature: Headings
145
146
  <p>non-heading content</p>
146
147
  </div>
147
148
  """
148
- When I validate the heading standards
149
+ When I validate the "content must follow headings" standard
149
150
  Then it fails with the message:
150
151
  """
151
- Heading elements must be followed by content. No content follows a h2.
152
+ No content follows: /html/body/div/h2[1]
152
153
  """
@@ -23,7 +23,7 @@ Feature: Image alternative content
23
23
  <img src="a.jpeg" alt="A picture of something" />
24
24
  <img src="b.jpeg" alt="" />
25
25
  """
26
- When I validate the image alt standards
26
+ When I validate the "images must have alt attributes" standard
27
27
  Then it passes
28
28
 
29
29
  Scenario: Images without alt attributes
@@ -32,8 +32,8 @@ Feature: Image alternative content
32
32
  <img src="a.jpeg" alt="A picture of something" />
33
33
  <img src="b.jpeg" />
34
34
  """
35
- When I validate the image alt standards
35
+ When I validate the "images must have alt attributes" standard
36
36
  Then it fails with the message:
37
37
  """
38
- Image has no alt attribute (src="b.jpeg")
38
+ Image has no alt attribute: /html/body/img[2]
39
39
  """
@@ -23,7 +23,7 @@ Feature: Specify content language
23
23
  </body>
24
24
  </html>
25
25
  """
26
- When I validate the language attribute standards
26
+ When I validate the "html must have lang attribute" standard
27
27
  Then it passes
28
28
 
29
29
  Scenario: Missing lang attribute on html element
@@ -39,8 +39,8 @@ Feature: Specify content language
39
39
  </body>
40
40
  </html>
41
41
  """
42
- When I validate the language attribute standards
42
+ When I validate the "html must have lang attribute" standard
43
43
  Then it fails with the message:
44
44
  """
45
- The main language must be specified. <html> tag has no lang attribute.
45
+ html tag has no lang attribute: /html
46
46
  """
@@ -12,7 +12,7 @@ Feature: Main landmark
12
12
  """
13
13
  <div role="main">Main element</div>
14
14
  """
15
- When I validate the landmark standards
15
+ When I validate the "exactly one main landmark" standard
16
16
  Then it passes
17
17
 
18
18
  Scenario: Page has two main elements
@@ -21,10 +21,10 @@ Feature: Main landmark
21
21
  <div role="main">Main one</div>
22
22
  <div role="main">Main two</div>
23
23
  """
24
- When I validate the landmark standards
24
+ When I validate the "exactly one main landmark" standard
25
25
  Then it fails with the message:
26
26
  """
27
- A document must have exactly one main landmark. Found 2 elements with role="main".
27
+ Found 2 elements with role="main": /html/body/div[1] /html/body/div[2]
28
28
  """
29
29
 
30
30
  Scenario: Page has zero main elements
@@ -32,8 +32,8 @@ Feature: Main landmark
32
32
  """
33
33
  <div role="not-main">Main one</div>
34
34
  """
35
- When I validate the landmark standards
35
+ When I validate the "exactly one main landmark" standard
36
36
  Then it fails with the message:
37
37
  """
38
- A document must have exactly one main landmark. Found 0 elements with role="main".
38
+ Found 0 elements with role="main".
39
39
  """
@@ -0,0 +1,36 @@
1
+ Feature: Minimum text size
2
+
3
+ At default browser level all text **must** have a minimum calculated size of
4
+ 11px and all core content **must** have a minimum calculated size of 13px.
5
+
6
+ Rationale
7
+ =========
8
+
9
+ Having a minimum text size will reduce the number of users who need to make
10
+ use of browser based text resize or page zoom. This is a particular issue with
11
+ an ageing audience, many of whom will not consider themselves as having low
12
+ vision and there will not have access to assistive technology or be familiar
13
+ with browser tools to resize content.
14
+
15
+ Scenario: Small text
16
+ Given a page with the HTML:
17
+ """
18
+ <style>
19
+ body {
20
+ font-size: 62.5%; /* Set default size of 1em to 10px */
21
+ }
22
+
23
+ b {
24
+ font-size: 9px;
25
+ }
26
+ </style>
27
+ <span>Some text</span> with <span>more <b>text</b> also</span>.
28
+ """
29
+ When I validate the "minimum text size" standard
30
+ Then it fails with the message:
31
+ """
32
+ Text size too small (10px): /html/body
33
+ Text size too small (10px): /html/body/span[1]
34
+ Text size too small (10px): /html/body/span[2]
35
+ Text size too small (9px): /html/body/span[2]/b
36
+ """
@@ -24,7 +24,7 @@ Feature: Correctly use `tabindex` attributes
24
24
  <button type="submit">Search</button>
25
25
  <div tabindex="-1"></div>
26
26
  """
27
- When I validate the tab index standards
27
+ When I validate the "elements with zero tab index must be fields" standard
28
28
  Then it passes
29
29
 
30
30
  Scenario: Focusable elements with zero tab index
@@ -36,7 +36,7 @@ Feature: Correctly use `tabindex` attributes
36
36
  <select tabindex="0"></select>
37
37
  <textarea tabindex="0"></textarea>
38
38
  """
39
- When I validate the tab index standards
39
+ When I validate the "elements with zero tab index must be fields" standard
40
40
  Then it passes
41
41
 
42
42
  Scenario: Unfocusable element with zero tab index
@@ -47,8 +47,8 @@ Feature: Correctly use `tabindex` attributes
47
47
  <div tabindex="3"></div>
48
48
  <div tabindex="0"></div>
49
49
  """
50
- When I validate the tab index standards
50
+ When I validate the "elements with zero tab index must be fields" standard
51
51
  Then it fails with the message:
52
52
  """
53
- tabindex="0" must not be used on <div> elements (not focusable by default)
53
+ Non-field element with tabindex=0: /html/body/div[2]
54
54
  """
@@ -23,7 +23,7 @@ Feature: Correctly use `title` attributes
23
23
  <img src="close.png" />
24
24
  </button>
25
25
  """
26
- When I validate the title attribute standards
26
+ When I validate the "title attributes only on inputs" standard
27
27
  Then it passes
28
28
 
29
29
  Scenario: Anchor tag with title attribute
@@ -33,8 +33,8 @@ Feature: Correctly use `title` attributes
33
33
  <img src="close.png" />
34
34
  </a>
35
35
  """
36
- When I validate the title attribute standards
36
+ When I validate the "title attributes only on inputs" standard
37
37
  Then it fails with the message:
38
38
  """
39
- Element (not a form input) has a title attribute: /html/body/a
39
+ Non-input element has title attribute: /html/body/a
40
40
  """
@@ -0,0 +1,15 @@
1
+ Feature: Coloured Output
2
+ To make console output easy to interpret
3
+ Only terminals that support coloured output should show colours
4
+
5
+ @keep-ansi-escape-sequences
6
+ Scenario: TTY terminals show coloured output
7
+ Given I am using a TTY terminal
8
+ When I run a11y against a failing page
9
+ Then I see red in the output
10
+
11
+ @keep-ansi-escape-sequences
12
+ Scenario: Non-TTY terminals show monochrome output
13
+ Given I am using a Non-TTY terminal
14
+ When I run a11y against a failing page
15
+ Then I see monochrome output
@@ -6,5 +6,5 @@ Feature: Display failing result
6
6
  Then it should fail with:
7
7
  """
8
8
  ✗ http://localhost:54321/missing_header.html
9
- - A document must have exactly one main heading. Found 0 h1 elements.
9
+ - Found 0 h1 elements.
10
10
  """
@@ -7,11 +7,11 @@ Feature: Display result summary
7
7
  page "http://localhost:54321/perfect.html"
8
8
  page "http://localhost:54321/missing_header.html"
9
9
  page "http://localhost:54321/missing_header.html?again!" do
10
- skip_standard /ExactlyOneMainHeading/
10
+ skip_standard "exactly one main heading"
11
11
  end
12
12
  """
13
13
  When I run `a11y`
14
14
  Then it should fail with:
15
15
  """
16
- Tested 3 pages, errors: 1, skipped: 1
16
+ 3 pages checked, 1 error found, 1 standard skipped
17
17
  """
@@ -0,0 +1,10 @@
1
+ Feature: Missing configuration file warning
2
+
3
+ Scenario: Running the tool with no arguments and no config file
4
+ When I run `a11y`
5
+ Then it should fail with:
6
+ """
7
+ Missing configuration file (a11y.rb).
8
+
9
+ Please visit http://www.rubydoc.info/gems/bbc-a11y for more information.
10
+ """
@@ -5,7 +5,7 @@ Feature: Skipping Standards
5
5
  And a file named "a11y.rb" with:
6
6
  """
7
7
  page "http://localhost:54321/missing_header.html" do
8
- skip_standard /head/i
8
+ skip_standard "exactly one main heading"
9
9
  end
10
10
  """
11
11
  When I run `a11y`
@@ -16,10 +16,10 @@ Feature: Mute errors
16
16
  """
17
17
  <p>yo</p>
18
18
  """
19
- When I validate the exactly one main heading standard
19
+ When I validate the "exactly one main heading" standard
20
20
  Then it fails with the message:
21
21
  """
22
- A document must have exactly one main heading. Found 0 h1 elements.
22
+ Found 0 h1 elements.
23
23
  """
24
24
  When I add a configuration with:
25
25
  """
@@ -27,6 +27,6 @@ Feature: Mute errors
27
27
  "exactly-one-main-heading"
28
28
  ]
29
29
  """
30
- And I validate the exactly one main heading standard
30
+ And I validate the "exactly one main heading" standard
31
31
  Then it shows 0 errors, 1 muted
32
32
  And it passes