bbc-a11y 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +9 -0
  3. data/CONTRIBUTING.md +70 -8
  4. data/GETTINGSTARTED.md +65 -0
  5. data/LICENSE +1 -1
  6. data/README.md +12 -55
  7. data/Rakefile +1 -1
  8. data/a11y.rb +1 -3
  9. data/bbc-a11y.gemspec +0 -1
  10. data/features/check_standards/01_core_purpose.feature +39 -0
  11. data/features/check_standards/02_validation.feature +1 -0
  12. data/features/check_standards/03_progressive_enhancement.feature +3 -0
  13. data/features/check_standards/{language.feature → 04_indicating_language.feature} +2 -2
  14. data/features/check_standards/05_page_titles.feature +1 -0
  15. data/features/check_standards/{main_landmark.feature → 06_main_landmark.feature} +6 -6
  16. data/features/check_standards/07_headings.feature +222 -0
  17. data/features/check_standards/{minimum_text_size.feature → 08_minimum_text_size.feature} +22 -2
  18. data/features/check_standards/09_resizable_text.feature +2 -0
  19. data/features/check_standards/{tab_index.feature → 10_tab_index.feature} +7 -7
  20. data/features/check_standards/{title_attribute.feature → 11_title_attributes.feature} +13 -5
  21. data/features/check_standards/{focusable_controls.feature → 12_focusable_controls.feature} +4 -4
  22. data/features/check_standards/13_visible_on_focus.feature +1 -0
  23. data/features/check_standards/14_control_styles.feature +1 -0
  24. data/features/check_standards/15_focus_styles.feature +1 -0
  25. data/features/check_standards/16_colour_contrast.feature +1 -0
  26. data/features/check_standards/17_colour_and_meaning.feature +1 -0
  27. data/features/check_standards/{image_alt.feature → 18_image_alternatives.feature} +5 -5
  28. data/features/check_standards/{form_labels.feature → 19_form_labels.feature} +7 -7
  29. data/features/check_standards/{form_interactions.feature → 20_form_interactions.feature} +6 -6
  30. data/features/check_standards/21_tables.feature +1 -0
  31. data/features/cli/display_failing_result.feature +14 -1
  32. data/features/cli/display_result_summary.feature +15 -1
  33. data/features/cli/provide_muting_tips.feature +1 -1
  34. data/features/cli/skipping_standards.feature +1 -1
  35. data/features/mute_errors.feature +2 -2
  36. data/features/step_definitions/steps.rb +10 -9
  37. data/features/support/web_server.rb +0 -11
  38. data/features/support/web_server/blank.html +7 -0
  39. data/features/support/web_server/two_headings_failures.html +11 -0
  40. data/karma.conf.js +1 -1
  41. data/lib/bbc/a11y/cli.rb +33 -6
  42. data/lib/bbc/a11y/js/bundle.js +139 -89
  43. data/lib/bbc/a11y/js/standards.js +67 -20
  44. data/lib/bbc/a11y/js/standards/{anchorsMustHaveHrefs.js → focusableControls/anchorsMustHaveHrefs.js} +0 -0
  45. data/lib/bbc/a11y/js/standards/{formsMustHaveSubmitButtons.js → formInteractions/formsMustHaveSubmitButtons.js} +0 -0
  46. data/lib/bbc/a11y/js/standards/{fieldsMustHaveLabelsOrTitles.js → formLabels/fieldsMustHaveLabelsOrTitles.js} +0 -0
  47. data/lib/bbc/a11y/js/standards/headings/contentMustFollowHeadings.js +18 -0
  48. data/lib/bbc/a11y/js/standards/{exactlyOneMainHeading.js → headings/exactlyOneMainHeading.js} +1 -1
  49. data/lib/bbc/a11y/js/standards/{headingsMustBeInAscendingOrder.js → headings/headingsMustBeInAscendingOrder.js} +0 -0
  50. data/lib/bbc/a11y/js/standards/{imagesMustHaveAltAttributes.js → imageAlternatives/imagesMustHaveAltAttributes.js} +0 -0
  51. data/lib/bbc/a11y/js/standards/{htmlMustHaveLangAttribute.js → indicatingLanguage/htmlMustHaveLangAttribute.js} +0 -0
  52. data/lib/bbc/a11y/js/standards/{exactlyOneMainLandmark.js → mainLandmark/exactlyOneMainLandmark.js} +0 -0
  53. data/lib/bbc/a11y/js/standards/{minimumTextSize.js → minimumTextSize/textCannotBeTooSmall.js} +3 -3
  54. data/lib/bbc/a11y/js/standards/{elementsWithZeroTabIndexMustBeFields.js → tabIndex/elementsWithZeroTabIndexMustBeFields.js} +0 -0
  55. data/lib/bbc/a11y/js/standards/{titleAttributesOnlyOnInputs.js → titleAttributes/titleAttributesOnlyOnInputs.js} +1 -1
  56. data/lib/bbc/a11y/linter.rb +16 -4
  57. data/lib/bbc/a11y/runner.rb +0 -1
  58. data/lib/bbc/a11y/string_colours.rb +15 -0
  59. data/lib/bbc/a11y/version +1 -1
  60. data/package.json +3 -0
  61. data/spec/bbc/a11y/js/a11ySpec.js +15 -6
  62. data/spec/bbc/a11y/js/minimumTextSizeStandardSpec.js +25 -0
  63. data/spec/bbc/a11y/js/standardsSpec.js +6 -6
  64. data/spec/bbc/a11y/string_colours_spec.rb +13 -0
  65. metadata +68 -102
  66. data/circle.yml +0 -3
  67. data/examples/bbc-pages/Gemfile +0 -3
  68. data/examples/bbc-pages/Rakefile +0 -3
  69. data/examples/bbc-pages/a11y.rb +0 -2
  70. data/examples/local-web-app/Gemfile +0 -4
  71. data/examples/local-web-app/Rakefile +0 -3
  72. data/examples/local-web-app/a11y.rb +0 -52
  73. data/examples/local-web-app/config.ru +0 -1
  74. data/examples/local-web-app/public/missing_header.html +0 -13
  75. data/examples/local-web-app/public/perfect.html +0 -14
  76. data/examples/local-web-app/readme.md +0 -0
  77. data/features/check_standards/headings.feature +0 -153
  78. data/lib/bbc/a11y/js/standards/contentMustFollowHeadings.js +0 -15
  79. data/lib/bbc/a11y/standards.rb +0 -45
  80. data/lib/bbc/a11y/standards/anchor_hrefs.rb +0 -18
  81. data/lib/bbc/a11y/standards/content_follows_headings.rb +0 -22
  82. data/lib/bbc/a11y/standards/exactly_one_main_heading.rb +0 -25
  83. data/lib/bbc/a11y/standards/exactly_one_main_landmark.rb +0 -20
  84. data/lib/bbc/a11y/standards/form_labels.rb +0 -39
  85. data/lib/bbc/a11y/standards/form_submit_buttons.rb +0 -21
  86. data/lib/bbc/a11y/standards/heading_hierarchy.rb +0 -34
  87. data/lib/bbc/a11y/standards/image_alt.rb +0 -18
  88. data/lib/bbc/a11y/standards/language_attribute.rb +0 -19
  89. data/lib/bbc/a11y/standards/tab_index.rb +0 -22
  90. data/lib/bbc/a11y/standards/title_attribute.rb +0 -31
  91. data/standards/01_core-purpose.md +0 -24
  92. data/standards/02_validation.feature +0 -31
  93. data/standards/03_javascript.feature +0 -40
  94. data/standards/04_language.feature +0 -58
  95. data/standards/05_page_title.feature +0 -45
  96. data/standards/06_main_landmark.feature +0 -24
  97. data/standards/07_headings.feature +0 -65
  98. data/standards/08_title_attribute.feature +0 -71
  99. data/standards/09_tabindex.feature +0 -51
  100. data/standards/10_form_labels.feature +0 -88
  101. data/standards/11_visible-on-focus.md +0 -58
  102. data/standards/13_colour-contrast.md +0 -27
  103. data/standards/14_colour-meaning.md +0 -19
  104. data/standards/15_focusable-controls.md +0 -45
  105. data/standards/16_table.md +0 -109
  106. data/standards/17_control-styles.md +0 -78
  107. data/standards/18_focus-styles.md +0 -36
  108. data/standards/19_form-interactions.md +0 -33
  109. data/standards/20_image-alt.md +0 -34
  110. data/standards/21_min-font-sizes.md +0 -64
  111. data/standards/22_resize-zoom.md +0 -80
  112. data/standards/step_definitions/core_content_steps.rb +0 -3
  113. data/standards/step_definitions/form_steps.rb +0 -6
  114. data/standards/step_definitions/language_steps.rb +0 -21
  115. data/standards/step_definitions/page_steps.rb +0 -50
  116. data/standards/step_definitions/w3c_steps.rb +0 -7
  117. data/standards/support/capybara.rb +0 -53
  118. data/standards/support/skipper.rb +0 -5
  119. data/standards/support/world.rb +0 -3
  120. data/standards/support/world_extender.rb +0 -5
@@ -13,7 +13,7 @@ Feature: Minimum text size
13
13
  with browser tools to resize content.
14
14
 
15
15
  Scenario: Small text
16
- Given a page with the HTML:
16
+ Given a page with the body:
17
17
  """
18
18
  <style>
19
19
  body {
@@ -26,7 +26,7 @@ Feature: Minimum text size
26
26
  </style>
27
27
  <span>Some text</span> with <span>more <b>text</b> also</span>.
28
28
  """
29
- When I validate the "minimum text size" standard
29
+ When I validate the "Minimum text size: text cannot be too small" standard
30
30
  Then it fails with the message:
31
31
  """
32
32
  Text size too small (10px): /html/body
@@ -34,3 +34,23 @@ Feature: Minimum text size
34
34
  Text size too small (10px): /html/body/span[2]
35
35
  Text size too small (9px): /html/body/span[2]/b
36
36
  """
37
+
38
+ Scenario: Hidden elements with small text
39
+ Given a page with the body:
40
+ """
41
+ <style>
42
+ span { display: none; }
43
+ </style>
44
+ <span style="font-size: 1px">Tiny text, but it's hidden!</span>
45
+ """
46
+ When I validate the "Minimum text size: text cannot be too small" standard
47
+ Then it passes
48
+
49
+ Scenario: Text nodes with only whitespace
50
+ Given a page with the body:
51
+ """
52
+ <div id="blq-global" style="font-size: 1px"> <div id="blq-pre-mast"> </div> &nbsp;
53
+ </div>
54
+ """
55
+ When I validate the "Minimum text size: text cannot be too small" standard
56
+ Then it passes
@@ -0,0 +1,2 @@
1
+ Feature: Resizable Text
2
+
@@ -1,4 +1,4 @@
1
- Feature: Correctly use `tabindex` attributes
1
+ Feature: Tab Index
2
2
 
3
3
  Positive `tabindex` attribute values **must not** be used to create a logical tab order.
4
4
 
@@ -18,17 +18,17 @@ Feature: Correctly use `tabindex` attributes
18
18
  control such as a `<a>` or `<button>`.
19
19
 
20
20
  Scenario: Element with negative tab index
21
- Given a page with the HTML:
21
+ Given a page with the body:
22
22
  """
23
23
  <a href="/news">News</a>
24
24
  <button type="submit">Search</button>
25
25
  <div tabindex="-1"></div>
26
26
  """
27
- When I validate the "elements with zero tab index must be fields" standard
27
+ When I validate the "Tab index: 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
31
- Given a page with the HTML:
31
+ Given a page with the body:
32
32
  """
33
33
  <a href="/news" tabindex="0">News</a>
34
34
  <button tabindex="0">Search</button>
@@ -36,18 +36,18 @@ Feature: Correctly use `tabindex` attributes
36
36
  <select tabindex="0"></select>
37
37
  <textarea tabindex="0"></textarea>
38
38
  """
39
- When I validate the "elements with zero tab index must be fields" standard
39
+ When I validate the "Tab index: 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
43
- Given a page with the HTML:
43
+ Given a page with the body:
44
44
  """
45
45
  <a href="/news" tabindex="1">News</a>
46
46
  <button type="submit" tabindex="2">Search</button>
47
47
  <div tabindex="3"></div>
48
48
  <div tabindex="0"></div>
49
49
  """
50
- When I validate the "elements with zero tab index must be fields" standard
50
+ When I validate the "Tab index: elements with zero tab index must be fields" standard
51
51
  Then it fails with the message:
52
52
  """
53
53
  Non-field element with tabindex=0: /html/body/div[2]
@@ -1,4 +1,4 @@
1
- Feature: Correctly use `title` attributes
1
+ Feature: Title Attributes
2
2
 
3
3
  `title` attributes **must not** be used for critical information and **must not** repeat content that is already visible and associated with the same control or content.
4
4
 
@@ -17,23 +17,31 @@ Feature: Correctly use `title` attributes
17
17
  - Do not use `title` attributes and explicit labels together on form fields
18
18
 
19
19
  Scenario: Form field with title attribute
20
- Given a page with the HTML:
20
+ Given a page with the body:
21
21
  """
22
22
  <button type="button" title="Close Button">
23
23
  <img src="close.png" />
24
24
  </button>
25
25
  """
26
- When I validate the "title attributes only on inputs" standard
26
+ When I validate the "Title attributes: title attributes only on inputs" standard
27
+ Then it passes
28
+
29
+ Scenario: Hidden element with title attribute
30
+ Given a page with the body:
31
+ """
32
+ <iframe style="display:none" title="Ignore me, I'm invisible"></iframe>
33
+ """
34
+ When I validate the "Title attributes: title attributes only on inputs" standard
27
35
  Then it passes
28
36
 
29
37
  Scenario: Anchor tag with title attribute
30
- Given a page with the HTML:
38
+ Given a page with the body:
31
39
  """
32
40
  <a href="close" title="Close Button">
33
41
  <img src="close.png" />
34
42
  </a>
35
43
  """
36
- When I validate the "title attributes only on inputs" standard
44
+ When I validate the "Title attributes: title attributes only on inputs" standard
37
45
  Then it fails with the message:
38
46
  """
39
47
  Non-input element has title attribute: /html/body/a
@@ -33,7 +33,7 @@ Feature: Focusable Controls
33
33
  causing confusion to users.
34
34
 
35
35
  Scenario: All anchor tags have href attributes
36
- Given a page with the HTML:
36
+ Given a page with the body:
37
37
  """
38
38
  <button type="button">Open panel</button>
39
39
  <ul>
@@ -42,11 +42,11 @@ Feature: Focusable Controls
42
42
  <li><a href="#entertainmenttab">Entertainment</a></li>
43
43
  </ul>
44
44
  """
45
- When I validate the "anchors must have hrefs" standard
45
+ When I validate the "Focusable controls: anchors must have hrefs" standard
46
46
  Then it passes
47
47
 
48
48
  Scenario: Some anchor tags do not have href attributes
49
- Given a page with the HTML:
49
+ Given a page with the body:
50
50
  """
51
51
  <ul>
52
52
  <li><a>News</a></li>
@@ -54,7 +54,7 @@ Feature: Focusable Controls
54
54
  <li><a>Entertainment</a></li>
55
55
  </ul>
56
56
  """
57
- When I validate the "anchors must have hrefs" standard
57
+ When I validate the "Focusable controls: 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
@@ -0,0 +1 @@
1
+ Feature: Visible On Focus
@@ -0,0 +1 @@
1
+ Feature: Control Styles
@@ -0,0 +1 @@
1
+ Feature: Focus Styles
@@ -0,0 +1 @@
1
+ Feature: Colour Contrast
@@ -0,0 +1 @@
1
+ Feature: Colour And Meaning
@@ -1,4 +1,4 @@
1
- Feature: Image alternative content
1
+ Feature: Image Alternatives
2
2
 
3
3
  All images **must** have an alt attribute.
4
4
 
@@ -18,21 +18,21 @@ Feature: Image alternative content
18
18
  the value of the alt attribute or in the immediately surrounding text content.
19
19
 
20
20
  Scenario: Images with alt attributes
21
- Given a page with the HTML:
21
+ Given a page with the body:
22
22
  """
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 "images must have alt attributes" standard
26
+ When I validate the "Image alternatives: images must have alt attributes" standard
27
27
  Then it passes
28
28
 
29
29
  Scenario: Images without alt attributes
30
- Given a page with the HTML:
30
+ Given a page with the body:
31
31
  """
32
32
  <img src="a.jpeg" alt="A picture of something" />
33
33
  <img src="b.jpeg" />
34
34
  """
35
- When I validate the "images must have alt attributes" standard
35
+ When I validate the "Image alternatives: images must have alt attributes" standard
36
36
  Then it fails with the message:
37
37
  """
38
38
  Image has no alt attribute: /html/body/img[2]
@@ -1,4 +1,4 @@
1
- Feature: Correctly use form labels
1
+ Feature: Form Labels
2
2
 
3
3
  Form fields that allow input (`select`, and `textarea` elements, and all
4
4
  `input` element types other than image, submit, reset, button, or hidden)
@@ -17,7 +17,7 @@ Feature: Correctly use form labels
17
17
  reasonably expect to be able to use.
18
18
 
19
19
  Scenario: All fields have labels or title attributes
20
- Given a page with the HTML:
20
+ Given a page with the body:
21
21
  """
22
22
  <label for="search">Search the BBC</label>
23
23
  <input type="text" id="search" name="q" />
@@ -29,11 +29,11 @@ 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 "fields must have labels or titles" standard
32
+ When I validate the "Form labels: fields must have labels or titles" standard
33
33
  Then it passes
34
34
 
35
35
  Scenario: Some fields without labels or title attributes
36
- Given a page with the HTML:
36
+ Given a page with the body:
37
37
  """
38
38
  <input type="text" name="name" title="Name" />
39
39
  <input type="email" name="email" title="Email" />
@@ -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 "fields must have labels or titles" standard
47
+ When I validate the "Form labels: 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
@@ -56,9 +56,9 @@ Feature: Correctly use form labels
56
56
 
57
57
  Scenario: Hidden fields do not need titles
58
58
 
59
- Given a page with the HTML:
59
+ Given a page with the body:
60
60
  """
61
61
  <input type=hidden name=a value=b>
62
62
  """
63
- When I validate the "fields must have labels or titles" standard
63
+ When I validate the "Form labels: fields must have labels or titles" standard
64
64
  Then it passes
@@ -19,7 +19,7 @@ Feature: Form Interactions
19
19
  beneficial to low vision users as an indication of the end of the form.
20
20
 
21
21
  Scenario: Form with a submit input
22
- Given a page with the HTML:
22
+ Given a page with the body:
23
23
  """
24
24
  <form action="/search">
25
25
  <label for="q">Search term:</label>
@@ -27,24 +27,24 @@ Feature: Form Interactions
27
27
  <input type="submit" value="Search">
28
28
  </form>
29
29
  """
30
- When I validate the "forms must have submit buttons" standard
30
+ When I validate the "Form interactions: forms must have submit buttons" standard
31
31
  Then it passes
32
32
 
33
33
  Scenario: Form with no submit button
34
- Given a page with the HTML:
34
+ Given a page with the body:
35
35
  """
36
36
  <form action="/search">
37
37
  <label for="q">Search term:</label>
38
38
  <input type="text" name="q" id="q">
39
39
  </form>
40
40
  """
41
- When I validate the "forms must have submit buttons" standard
41
+ When I validate the "Form interactions: 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
45
45
  """
46
46
  Scenario: Form with a submit button
47
- Given a page with the HTML:
47
+ Given a page with the body:
48
48
  """
49
49
  <form action="/search">
50
50
  <label for="q">Search term:</label>
@@ -52,5 +52,5 @@ Feature: Form Interactions
52
52
  <button type="submit">Search</button>
53
53
  </form>
54
54
  """
55
- When I validate the "forms must have submit buttons" standard
55
+ When I validate the "Form interactions: forms must have submit buttons" standard
56
56
  Then it passes
@@ -0,0 +1 @@
1
+ Feature: Tables
@@ -6,5 +6,18 @@ Feature: Display failing result
6
6
  Then it should fail with:
7
7
  """
8
8
  ✗ http://localhost:54321/missing_header.html
9
- - Found 0 h1 elements.
9
+ * Headings: Exactly one main heading
10
+ - Found 0 h1 elements.
11
+ """
12
+
13
+ Scenario: Two standards fail
14
+ Given a website running at http://localhost:54321
15
+ When I run `a11y http://localhost:54321/two_headings_failures.html`
16
+ Then it should fail with:
17
+ """
18
+ ✗ http://localhost:54321/two_headings_failures.html
19
+ * Headings: Content must follow headings
20
+ - No content follows: /html/body/h2
21
+ * Headings: Exactly one main heading
22
+ - Found 0 h1 elements.
10
23
  """
@@ -7,7 +7,7 @@ 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 "exactly one main heading"
10
+ skip_standard "Headings: exactly one main heading"
11
11
  end
12
12
  """
13
13
  When I run `a11y`
@@ -15,3 +15,17 @@ Feature: Display result summary
15
15
  """
16
16
  3 pages checked, 1 error found, 1 standard skipped
17
17
  """
18
+
19
+ Scenario: Reminds users to consider usability beyond lint results
20
+ Given a website running at http://localhost:54321
21
+ When I run `a11y http://localhost:54321/perfect.html`
22
+ Then it should pass with:
23
+ """
24
+ No errors found. But please remember:
25
+
26
+ "Testing shows the presence, not the absence of bugs" -- Edsger W. Dijkstra
27
+
28
+ I am only a robot. Always make time to perform manual testing using assistive
29
+ technologies like VoiceOver, JAWS and NVDA to make sure you're providing a good
30
+ user experience.
31
+ """
@@ -5,7 +5,7 @@ Feature: Provide muting tips
5
5
  warning.
6
6
 
7
7
  Scenario: Generate a warning where there are several bad elements
8
- Given a page with the HTML:
8
+ Given a page with the body:
9
9
  """
10
10
  <div id="my-amazing-code">
11
11
  <h1>I am wonderfull</h1>
@@ -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 "exactly one main heading"
8
+ skip_standard "Headings: exactly one main heading"
9
9
  end
10
10
  """
11
11
  When I run `a11y`
@@ -12,11 +12,11 @@ Feature: Mute errors
12
12
  real examples?
13
13
 
14
14
  Scenario: Mute any errors from a specific standard
15
- Given a page with the HTML:
15
+ Given a page with the body:
16
16
  """
17
17
  <p>yo</p>
18
18
  """
19
- When I validate the "exactly one main heading" standard
19
+ When I validate the "Headings: exactly one main heading" standard
20
20
  Then it fails with the message:
21
21
  """
22
22
  Found 0 h1 elements.
@@ -1,6 +1,5 @@
1
1
  require 'capybara'
2
2
  require 'bbc/a11y/linter'
3
- require 'bbc/a11y/standards'
4
3
  require 'bbc/a11y/javascript'
5
4
 
6
5
  Given(/^a website running at http:\/\/localhost:(\d+)$/) do |port|
@@ -17,21 +16,23 @@ Given(/^one test fails$/) do
17
16
  step "I run `a11y http://localhost:54321/missing_header.html`"
18
17
  end
19
18
 
20
- Given(/^a page with the HTML:$/) do |string|
19
+ Given(/^a page with the HTML:$/) do |html|
21
20
  WebServer.ensure_running_on(54321)
22
- WebServer.write_page "scenario.html", "<html><body>#{string}</body></html>"
23
- browser.visit 'http://localhost:54321/scenario.html'
21
+ browser.visit 'http://localhost:54321/blank.html'
22
+ browser.execute_script "document.write(#{html.to_json});"
24
23
  end
25
24
 
26
- After do
27
- WebServer.delete_page "scenario.html"
25
+ Given(/^a page with the body:$/) do |body_html|
26
+ WebServer.ensure_running_on(54321)
27
+ browser.visit 'http://localhost:54321/blank.html'
28
+ browser.execute_script "document.body.innerHTML = #{body_html.to_json}"
28
29
  end
29
30
 
30
31
  When(/^I validate the \"([^\"]+)\" standard$/) do |standard_name|
31
32
  browser.execute_script(BBC::A11y::Javascript.bundle)
32
33
  validation = browser.evaluate_script("a11y.validate(#{standard_name.to_json})")
33
34
  if validation['results'].size != 1
34
- raise "#{validation['results'].size} standards match '#{pattern}'"
35
+ raise "#{validation['results'].size} standards match '#{standard_name}' (expected 1 match)"
35
36
  end
36
37
  @result = BBC::A11y::LintResult.from_json(validation)
37
38
  end
@@ -42,7 +43,7 @@ end
42
43
 
43
44
  Then(/^it fails with the message:$/) do |message|
44
45
  expect(@result).to be_failed
45
- expect(@result.to_s).to eq message.to_s
46
+ expect(@result.errors.map { |e| e.message}.join("\n")).to eq message
46
47
  end
47
48
 
48
49
  Given(/^I am using a TTY terminal$/) do
@@ -60,7 +61,7 @@ end
60
61
 
61
62
  Then(/^I see red in the output$/) do
62
63
  all_output = all_commands.map { |c| c.output }.join("\n")
63
- expect(all_output).to include('[0;31;49m')
64
+ expect(all_output).to include("\e[31m")
64
65
  end
65
66
 
66
67
  Then(/^I see monochrome output$/) do