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
@@ -1,78 +0,0 @@
1
- # Links must be self-evident
2
-
3
- Links that are part of general editorial content **must** be identifiable by there visual style and be distinguishable from the surrounding content.
4
-
5
- Text links **must** have a mouse-over state change.
6
-
7
- ## Rationale
8
-
9
- To aid discoverability all links must be made self-evident with their visual style.
10
-
11
- Appropriate styles are:
12
-
13
- - underlined
14
- - a different colour, meeting contrast standards, to the surrounding text
15
-
16
- When hovered over links should have a change in style as confirmation that they are links.
17
-
18
- Appropriate styles are:
19
-
20
- - adding an underline to previously not underlined content
21
- - a change in colour, with a sufficiently different contrast to meet the contrast standard compared with the default state colour
22
-
23
- ## Techniques
24
-
25
- Pass:
26
-
27
- <style>
28
- body {
29
- background: #fff;
30
- color: #000;
31
- }
32
-
33
- a {
34
- color: #005580;
35
- text-decoration: none;
36
- }
37
-
38
- a:focus,
39
- a:hover {
40
- background:
41
- text-decoration: underline;
42
- }
43
- </style>
44
-
45
- <a href="http://www.bbc.co.uk/">BBC</a>
46
-
47
- Fail:
48
-
49
- <style>
50
- body {
51
- background: #fff;
52
- color: #000;
53
- }
54
-
55
- a {
56
- color: #000;
57
- text-decoration: none;
58
- }
59
- </style>
60
-
61
- <a href="http://www.bbc.co.uk/">BBC</a>
62
-
63
- ## Tests
64
-
65
- | Procedure | Expected Result | Type |
66
- | --------- | --------------- | ---- |
67
- | For every `<a>` element check the visual style | All `<a>` elements must be visually distinguishable from the surrounding content | Manual |
68
- | For every `<a>` element check the visual style of the `:hover` state | All `<a>` elements must have a visually distinguishable style between `:link` and `:hover` states | Manual |
69
-
70
- --
71
-
72
- ## Notes
73
-
74
- Might be difficult to automate the first test. It might be possible (but expensive) to check every link on a page against the style of its parent element, comparing colour, underlines, weight, and other styles but at best I feel this could only be an error if there are no style changes.
75
-
76
- The second test is testing two states of the same element so might not be quite as difficult (providing you have access to the :hover styles) but it's still hard to have a high degree of confidence in the outcome.
77
-
78
- Perhaps we need to have a warning rather than an error for these tests.
@@ -1,36 +0,0 @@
1
- # Focusable elements must have a clear visual indication when they receive focus
2
-
3
- All focusable elements **must** have a clearly identifiable visual style when they have focus
4
-
5
- ## Rationale
6
-
7
- Sighted keyboard users do not have the explicit association between pointer and content that pointing device users have, so it is important that they are aware at all times what element currently has focus and which element keyboard interactions will operate on.
8
-
9
- The currently focussed element should therefore have a visual style that makes it clearly distinguishable from the surrounding content.
10
-
11
- ## Techniques
12
-
13
- Pass:
14
-
15
- <style>
16
- a {
17
- text-decoration: none;
18
- }
19
- a:focus {
20
- text-decoration: underline;
21
- }
22
- </style>
23
-
24
- Fail:
25
-
26
- <style>
27
- a {
28
- outline: none;
29
- }
30
- </style>
31
-
32
- ## Test
33
-
34
- | Procedure | Expected Result | Type |
35
- | --------- | --------------- | ---- |
36
- | For every `<a>`, `<button>`, or other focusable element check the visual style of the `:focus` state | All `<a>`, `<button>`, and other focusable elements must have a visually distinguishable style between their regular and `:focus` states | Manual |
@@ -1,33 +0,0 @@
1
- # Forms must have a submit button and forms must not update the location of the page on change, focus, or blur events
2
-
3
- All `<form>` elements that take user input (i.e. do not consist only of `input[type=hidden]` elements to store state) **must** have a submit button in the form of a `<input>[type=submit,image]` or `<button>[type=submit]` element.
4
-
5
- Changes to the page **must** location must only take place on explicit user action i.e. when a submit button is activated. They must not take place when change (particularly for `select` elements), focus, or blur events are fired.
6
-
7
- ## Rationale
8
-
9
- All forms should have a submit button to provide a clear call to action. This is particularly important to users with cognitive disabilities, but is also beneficial to low vision users as an indication of the end of the form.
10
-
11
- ## Techniques
12
-
13
- Pass:
14
-
15
- <form action="/search">
16
- <label for="q">Search term:</label>
17
- <input type="text" name="q" id="q">
18
- <input type="submit" value="Search">
19
- </form>
20
-
21
- Fail:
22
-
23
- <form action="/search">
24
- <label for="q">Search term:</label>
25
- <input type="text" name="q" id="q">
26
- </form>
27
-
28
- ## Tests
29
-
30
- | Procedure | Expected Result | Type |
31
- | --------- | --------------- | ---- |
32
- | Identify every `<form>` or collection of form elements | Each `<form>` or collection of form elements must have a submit button | Manual |
33
- | Test each `<form>` or collection of form elements | Page location must not change on change, focus, or blur events | Manual |
@@ -1,34 +0,0 @@
1
- # Image alternative content
2
-
3
- All images **must** have an alt attribute.
4
-
5
- All editorial significant images **must** have a non-null alt attribute value, or a text alternative in the preceding or following content.
6
-
7
- ## Rationale
8
-
9
- Assistive technologies such as screen readers will provide a text alternative for images that do not have alt attributes based on the image file name. For images that do not have editorial significance or are described in the surrounding text content it is appropriate to use a null (alt="") value for the image alt attribute to avoid this.
10
-
11
- All editorially significantly images must have a text alternative either as the value of the alt attribute or in the immediately surrounding text content.
12
-
13
- ## Techniques
14
-
15
- Pass:
16
-
17
- <img src="bbc-logo.png" alt="BBC">
18
-
19
- <h1>Story headline</h1>
20
- <img src="story-image.png" alt="">
21
-
22
- Fail:
23
-
24
- <img src="bbc-logo.png">
25
-
26
- <h1>Story headline</h1>
27
- <img src="story-image.png" alt="Story headline">
28
-
29
- ## Tests
30
-
31
- | Procedure | Expected Result | Type |
32
- | --------- | --------------- | ---- |
33
- | Identify each image on the page | Every image must have an alt attribute | Manual |
34
- | Identify each editorially significant image on the page | Every editorially significant image must have a text alternative either as the value of the alt attribute or in the immediately surrounding text content. | Manual |
@@ -1,64 +0,0 @@
1
- # Minimum text size
2
-
3
- At default browser level all text **must** have a minimum calculated size of 11px and all core content **must** have a minimum calculated size of 13px.
4
-
5
- ## Rationale
6
-
7
- Having a minimum text size will reduce the number of users who need to make use of browser based text resize or page zoom. This is a particular issue with an ageing audience, many of whom will not consider themselves as having low vision and there will not have access to assistive technology or be familiar with browser tools to resize content.
8
-
9
- ## Definitions
10
-
11
- ### Core content
12
-
13
- The content that is required to fulfil the core purpose of the document or feature.
14
-
15
- ## Techniques
16
-
17
- Pass:
18
-
19
- <style>
20
- body {
21
- font-size: 62.5%; /* Set default size of 1em to 10px */
22
- }
23
-
24
- .news-article p {
25
- font-size: 1.3em; /* Primary content size set to 13px */
26
- }
27
-
28
- .news-supplimentary-links {
29
- font-size: 1.2em; /* Secondary content size set to 12px */
30
- }
31
- </style>
32
-
33
- Fail:
34
-
35
- <style>
36
- body {
37
- font-size: 62.5%; /* Set default size of 1em to 10px */
38
- }
39
-
40
- .news-article p {
41
- font-size: 1.2em; /* Primary content size set to 12px */
42
- }
43
-
44
- .news-supplimentary-links {
45
- font-size: 1em; /* Secondary content size set to 10px */
46
- }
47
- </style>
48
-
49
- ## Test
50
-
51
- | Procedure | Expected Result | Type |
52
- | --------- | --------------- | ---- |
53
- | For every piece of text of different sizes check the computed text size | All content must have a minimum size of 11px | Manual, automatable |
54
- | For every piece of core content text of different sizes check the computed text size | All core content must have a minimum size of 13px | Manual |
55
-
56
- --
57
-
58
- ## Notes
59
-
60
- The core content problem again so we can only realistically automate testing against the 11px minimum.
61
-
62
- It could be an expensive operation to get the computed style for every text node in a document, and it is tests like this that made me think about having grades of tests based on how quickly they are likely to run. You don't need to run this test every time a CSS change is made, but it is worth running before committing.
63
-
64
- It is likely that entire parts of the page will be considered 'core', for example everything in the page `<main>` element, so would it be possible to write this in such a way as to make it easy for individualy products to add their custom rules to test for the 13px minimum within certain elements?
@@ -1,80 +0,0 @@
1
- # Content must be resizable to 200
2
-
3
- Text **must** be styled with units that are resizable in all browsers.
4
-
5
- Content **must** be visible and usable with text resized to 200% of normal.
6
-
7
- Content **must** be visible and usable with page zoomed to 200% of normal.
8
-
9
- Where available on a platform zoom **must** be suported.
10
-
11
- ## Rationale
12
-
13
- Standard browser features for resizing text or page zoom can make content accessible to many low vision users without the need for additional assistive technologies such as screen magnifiers or screen readers.
14
-
15
- Text resizing and page zoom cater to different needs, and therefore both should be supported.
16
-
17
- Internet Explorer does not resize text that have been styled in `px` units, therefore `em`, `%` or similar units should be used.
18
-
19
- Browsers on iOS, Android, and other mobile platforms also support zoom with pinch-in and pinch-out gestures. In most cases it is just a matter of not disabling this, but there are some cases when it is appropriate to implement content specific interactions, such as with zoomable maps, which should mimic the same pinch-in and pinch-out gestures.
20
-
21
- ## Definitions
22
-
23
- ### Visible
24
-
25
- Content is not clipped and does not overlap other content, and has sufficient spacing to make it readable.
26
-
27
- ### Usable
28
-
29
- Links, forms, and other controls are not overlapped with other elements making them un-clickable.
30
-
31
- ## Techniques
32
-
33
- Pass:
34
-
35
- <style>
36
- body {
37
- font-size: 1.3em;
38
- }
39
- </style>
40
-
41
- <meta name="viewport" content="user-scalable=YES">
42
-
43
- <meta name="viewport" content="width=device-width;
44
- initial-scale=1.0; maximum-scale=2.0;
45
- user-scalable=1;">
46
-
47
- Fail:
48
-
49
- <style>
50
- body {
51
- font-size: 13px;
52
- }
53
- </style>
54
-
55
- <style>
56
- body {
57
- overflow: hidden;
58
- }
59
- </style>
60
-
61
- <meta name="viewport" content="user-scalable=no" />
62
-
63
- <meta name="viewport" content="width=device-width;
64
- initial-scale=1.0; maximum-scale=1.0;
65
- user-scalable=1;">
66
-
67
- ## Test
68
-
69
- | Procedure | Expected Result | Type |
70
- | --------- | --------------- | ---- |
71
- | In a browser that supports page zoom, increase the zoom level to 200% | All content must be visible and usable | Manual |
72
- | In a browser that supports text resize, increase text resize to 200% | All content must be visible and usable | Manual |
73
- | In Internet Explorer, increase text resize | All text content should increase in size | Manual |
74
- | On platforms that support it, use pinch-in and pinch-out to zoom content | All content should increase and descrease in size | Manual |
75
-
76
- --
77
-
78
- ## Notes
79
-
80
- The first two tests will have to be manual I think, but is it possible to make automate the 'px' test?
@@ -1,3 +0,0 @@
1
- Then(/^all core content is available and functional$/) do
2
- skip_this_scenario
3
- end
@@ -1,6 +0,0 @@
1
- Then(/^the following form elements must have a title attribute or associated label tag:$/) do |table|
2
- selectors = table.raw.flatten
3
- page.all_elements_matching(*selectors).each do |element|
4
- expect(element).to have_title_attribute_or_associated_label_tag
5
- end
6
- end
@@ -1,21 +0,0 @@
1
- Then(/^the <html> element must have a `lang` attribute$/) do
2
- page.must_have_lang_attribute
3
- end
4
-
5
- Then(/^the main natural language of the page must match that attribute$/) do
6
- expected_language = language.detect(page)
7
- puts "Detected page language: #{expected_language}"
8
- page.must_have_lang_attribute_of(expected_language)
9
- end
10
-
11
- Then(/^any other tags with a lang attribute must contain text of that language$/) do
12
- pending # express the regexp above with the code you wish you had
13
- end
14
- Then(/^all elements with `lang` attribute must have content in that natural language$/) do
15
- pending # express the regexp above with the code you wish you had
16
- end
17
-
18
- Then(/^any parts expressed in a natural language different to the main language of the page must have a matching `lang` attribute$/) do
19
- pending # express the regexp above with the code you wish you had
20
- end
21
-
@@ -1,50 +0,0 @@
1
- When(/^I visit the page$/) do
2
- browser.visit settings.url
3
- end
4
-
5
- When(/^I view the page with JavaScript disabled$/) do
6
- disable_javascript_and_css
7
- browser.visit settings.url
8
- end
9
-
10
- Then(/^the document should have a title$/) do
11
- page.must_have_title
12
- end
13
-
14
- Then(/^the title should describe the primary content of the document$/) do
15
- begin
16
- page.must_have_title_that_contains_h1_text
17
- rescue Exception => error
18
- assert_title_describes_primary_content_of_document(browser.title, browser)
19
- end
20
- end
21
-
22
- Then(/^there should be exactly one element with `role="(.*?)"`$/) do |arg1|
23
- page.must_have_one_main_element
24
- end
25
-
26
- Then(/^there must be exactly one h1 element$/) do
27
- page.must_have_one_h1
28
- end
29
-
30
- Then(/^each heading must be followed by content or a heading of one level deeper \(h2\-h6\)$/) do
31
- puts "Heading hierarchy:"
32
- puts page.heading_hierarchy.to_s
33
- page.must_have_correct_heading_hierarchy
34
- end
35
-
36
- Then(/^there must be no elements with a title attribute whose content is repeated within the element$/) do
37
- page.must_have_no_elements_with_title_attribute_content_repeated_within
38
- end
39
-
40
- Then(/^any form fields with associated labels do not have a title attribute$/) do
41
- page.must_have_no_form_fields_with_label_and_title
42
- end
43
-
44
- Given(/^there should be no elements with a tabindex attribte of (\d+) or greater$/) do |max_tabindex|
45
- page.must_not_have_any_elements_with_tabindex_greater_than max_tabindex.to_i
46
- end
47
-
48
- Given(/^there should be no elements with a tabindex attribute of (\d+) except for:$/) do |tabindex, elements|
49
- page.must_not_have_elements_with_tabindex(tabindex.to_i, except: elements.raw.flatten)
50
- end
@@ -1,7 +0,0 @@
1
- When(/^I submit the page to the W3C Markup Validation Service$/) do
2
- w3c.validate settings.url
3
- end
4
-
5
- Then(/^there should be no errors$/) do
6
- expect(w3c.errors).to be_empty
7
- end
@@ -1,53 +0,0 @@
1
- require 'capybara'
2
- require 'capybara/dsl'
3
- require 'phantomjs/poltergeist'
4
-
5
- Capybara.register_driver :poltergeist do |app|
6
- Capybara::Poltergeist::Driver.new(app, js_errors: false)
7
- end
8
-
9
- Capybara.default_driver = :poltergeist
10
-
11
- Before do
12
- Capybara.use_default_driver
13
- end
14
-
15
- After do
16
- Capybara.reset_sessions!
17
- end
18
-
19
- module BBC
20
- module A11y
21
-
22
- module Browser
23
- def browser
24
- Capybara.current_session
25
- end
26
-
27
- def disable_javascript_and_css
28
- unless Capybara.drivers.keys.include?(:without_js)
29
- skip_this_scenario <<-ERROR
30
- You need to define a non-javascript driver for Capybara in order to run this scenario. Here's an example you could use:
31
-
32
- require 'capybara/selenium'
33
- Capybara.register_driver(:without_javascript_or_css) do |app|
34
- profile = Selenium::WebDriver::Firefox::Profile.new
35
- profile['permissions.default.stylesheet'] = 2
36
- profile['javascript.enabled'] = false
37
- Capybara::Selenium::Driver.new(app, profile: profile)
38
- end
39
-
40
- You can put this code into your a11y.rb file
41
-
42
- You'll also need to add the `selenium-webdriver` gem to your Gemfile.
43
- ERROR
44
- else
45
- Capybara.current_driver = :without_js
46
- end
47
- end
48
- end
49
-
50
- end
51
- end
52
-
53
- World(BBC::A11y::Browser)