bbc-a11y 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -31
- data/Rakefile +2 -1
- data/examples/bbc-pages/.a11y.rb +6 -0
- data/examples/bbc-pages/Gemfile +3 -0
- data/examples/bbc-pages/Rakefile +3 -0
- data/examples/local-web-app/Rakefile +3 -0
- data/features/step_definitions/page_steps.rb +1 -1
- data/features/support/capybara.rb +19 -7
- data/features/support/skipper.rb +1 -1
- data/lib/bbc/a11y/cli.rb +3 -4
- data/lib/bbc/a11y/cucumber_runner.rb +58 -9
- data/lib/bbc/a11y/cucumber_support/per_page_checks.rb +8 -8
- data/lib/bbc/a11y/version +1 -1
- metadata +12 -9
- data/example/Rakefile +0 -3
- /data/{example → examples/local-web-app}/.a11y.rb +0 -0
- /data/{example → examples/local-web-app}/Gemfile +0 -0
- /data/{example → examples/local-web-app}/config.ru +0 -0
- /data/{example → examples/local-web-app}/public/missing_header.html +0 -0
- /data/{example → examples/local-web-app}/public/perfect.html +0 -0
- /data/{example → examples/local-web-app}/readme.md +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02a747cee79f3519c0fc2124d6069462c8d3a567
|
4
|
+
data.tar.gz: 2206a476f841791cb74013b54f9403c3a3da39b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4945eae8117e5e223ac27d834d23196646f7e31b730d958fd5345d8d5928b16816ae828563304f9b9c7b6dbd7dd7aaced3fa3e1726104cc2026592f35684f43
|
7
|
+
data.tar.gz: 5f45f2a0bcb880de8f87edbeee24fc99b60899ab092d26495457e20ff2a77b7a8fbfcdbe615ee993270b46a139e6a760adfa69cd994529be9ed375ed9a728744
|
data/README.md
CHANGED
@@ -1,54 +1,60 @@
|
|
1
|
-
#
|
1
|
+
#BBC Accessiblity Standards
|
2
2
|
|
3
|
-
This tool runs a set of tests against a
|
3
|
+
This tool runs a set of tests against a set of URLs to verify whether each one meets the [BBC accessibility standards](http://www.bbc.co.uk/guidelines/futuremedia/accessibility/).
|
4
4
|
|
5
|
-
## How to
|
5
|
+
## How to install
|
6
6
|
|
7
|
-
|
7
|
+
bbc-a11y is packaged as a Ruby gem. You'll most likely want to create a stand-alone repo to run your accessibilty tests,
|
8
|
+
but you can also add it as part of an existing repo.
|
8
9
|
|
9
|
-
|
10
|
+
### Prerequisites
|
10
11
|
|
11
|
-
|
12
|
+
[Install Ruby](https://www.ruby-lang.org/en/documentation/installation/) and then:
|
12
13
|
|
13
|
-
|
14
|
-
after the `--` is passed directly to Cucumber. For example, to skip the tests that require manual interraction:
|
14
|
+
gem install bundler
|
15
15
|
|
16
|
-
|
16
|
+
### Adding a11y to your project's Gemfile
|
17
17
|
|
18
|
-
|
18
|
+
Create or amend your your project's `Gemfile` to include this line:
|
19
19
|
|
20
|
-
|
20
|
+
gem 'bbc-a11y`
|
21
21
|
|
22
|
-
|
22
|
+
Now install the gem:
|
23
23
|
|
24
|
-
|
24
|
+
bundle install
|
25
25
|
|
26
|
-
|
26
|
+
## Configuration
|
27
27
|
|
28
|
-
|
28
|
+
You'll need to configure a11y with a set of URLs to run the checks against. Create a file `.a11y.rb` in the root of your project that looks something like this:
|
29
29
|
|
30
|
-
|
30
|
+
```
|
31
|
+
BBC::A11y.configure do
|
32
|
+
page "http://bbc.co.uk"
|
33
|
+
page "http://bbc.co.uk/news"
|
34
|
+
end
|
35
|
+
```
|
31
36
|
|
32
|
-
|
37
|
+
### Skipping scenarios
|
33
38
|
|
34
|
-
|
39
|
+
Nobody's perfect. Use `skip_scenario` in the configuration to opt-out of certain checks.
|
35
40
|
|
36
|
-
|
41
|
+
```
|
42
|
+
BBC::A11y.configure do
|
43
|
+
page "http://bbc.co.uk" do
|
44
|
+
skip_scenario "W3C"
|
45
|
+
end
|
37
46
|
|
38
|
-
|
47
|
+
page "http://bbc.co.uk/news"
|
48
|
+
end
|
49
|
+
```
|
39
50
|
|
40
|
-
|
51
|
+
A11y will skip any scenarios from the specifications whose name contains that string.
|
41
52
|
|
42
|
-
|
43
|
-
2. Install dependencies
|
53
|
+
## Running it
|
44
54
|
|
45
|
-
|
46
|
-
cd bbc-a11y
|
47
|
-
bundle install
|
48
|
-
~~~
|
55
|
+
Once you're configured, you can run the tests using the `a11y` command:
|
49
56
|
|
50
|
-
|
57
|
+
bundle exec a11y
|
51
58
|
|
52
|
-
|
53
|
-
|
54
|
-
~~~
|
59
|
+
This will pick up your `.a11y.rb` configuration file and run the a11y features on each page specified in your configuration.
|
60
|
+
Output is printed to the console.
|
data/Rakefile
CHANGED
@@ -2,12 +2,6 @@ require 'capybara'
|
|
2
2
|
require 'capybara/dsl'
|
3
3
|
require 'capybara/poltergeist'
|
4
4
|
|
5
|
-
#Capybara.register_driver(:without_javascript_or_css) do |app|
|
6
|
-
# profile = Selenium::WebDriver::Firefox::Profile.new
|
7
|
-
# profile['permissions.default.stylesheet'] = 2
|
8
|
-
# profile['javascript.enabled'] = false
|
9
|
-
# Capybara::Selenium::Driver.new(app, profile: profile)
|
10
|
-
#end
|
11
5
|
|
12
6
|
Capybara.default_driver = :poltergeist
|
13
7
|
|
@@ -28,7 +22,25 @@ module BBC
|
|
28
22
|
end
|
29
23
|
|
30
24
|
def disable_javascript_and_css
|
31
|
-
|
25
|
+
unless Capybara.drivers.keys.include?(:without_js)
|
26
|
+
skip_this_scenario <<-ERROR
|
27
|
+
You need to define a non-javascript driver for Capybara in order to run this scenario. Here's an example you could use:
|
28
|
+
|
29
|
+
require 'capybara/selenium'
|
30
|
+
Capybara.register_driver(:without_javascript_or_css) do |app|
|
31
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
32
|
+
profile['permissions.default.stylesheet'] = 2
|
33
|
+
profile['javascript.enabled'] = false
|
34
|
+
Capybara::Selenium::Driver.new(app, profile: profile)
|
35
|
+
end
|
36
|
+
|
37
|
+
You can put this code into your .a11y.rb file
|
38
|
+
|
39
|
+
You'll also need to add the `selenium-webdriver` gem to your Gemfile.
|
40
|
+
ERROR
|
41
|
+
else
|
42
|
+
Capybara.current_driver = :without_js
|
43
|
+
end
|
32
44
|
end
|
33
45
|
end
|
34
46
|
|
data/features/support/skipper.rb
CHANGED
data/lib/bbc/a11y/cli.rb
CHANGED
@@ -29,17 +29,16 @@ module BBC
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def cucumber_args
|
32
|
-
return unless args.include?('--')
|
33
|
-
args[args.find_index('--')+1..-1]
|
32
|
+
return [] unless args.include?('--')
|
33
|
+
args[args.find_index('--')+1..-1]
|
34
34
|
end
|
35
35
|
|
36
36
|
attr_reader :stdin, :stderr, :stdout, :args
|
37
37
|
private :stdin, :stderr, :stdout, :args
|
38
38
|
|
39
39
|
HELP = %{
|
40
|
-
Usage: a11y
|
40
|
+
Usage: a11y [-- cucumber-args]
|
41
41
|
|
42
|
-
url-to-test - URL of the page to run the full set of accessiblity tests against
|
43
42
|
cucumber-args - Arguments to pass to Cucumber when running the tests. See cucumber --help
|
44
43
|
for details.
|
45
44
|
}
|
@@ -6,7 +6,19 @@ require 'colorize'
|
|
6
6
|
|
7
7
|
module BBC
|
8
8
|
module A11y
|
9
|
+
module ConsoleWriter
|
10
|
+
def underline(text, character="-")
|
11
|
+
[text, character * text.length].join("\n")
|
12
|
+
end
|
13
|
+
|
14
|
+
def indent(spaces, text)
|
15
|
+
text.split("\n").map { |line| (" " * spaces) + line }.join("\n")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
9
19
|
class CucumberFormatter
|
20
|
+
include ConsoleWriter
|
21
|
+
|
10
22
|
def initialize(*args)
|
11
23
|
@current_feature = nil
|
12
24
|
end
|
@@ -14,27 +26,41 @@ module BBC
|
|
14
26
|
def before_test_case(test_case)
|
15
27
|
on_new_feature(test_case) do |feature|
|
16
28
|
puts
|
17
|
-
puts
|
18
|
-
puts "#{"-" * feature.name.length}"
|
29
|
+
puts underline(feature.name)
|
19
30
|
puts
|
20
31
|
end
|
21
|
-
print " - #{test_case.name} "
|
32
|
+
print " - #{test_case.name}... "
|
33
|
+
@step_results = []
|
34
|
+
end
|
35
|
+
|
36
|
+
def after_test_step(test_step, result)
|
37
|
+
@step_results << [test_step, result]
|
22
38
|
end
|
23
39
|
|
24
40
|
def after_test_case(test_case, result)
|
25
41
|
colour = ResultColour.new(result)
|
26
42
|
print colour.apply_to(result.to_s)
|
27
|
-
if result.
|
43
|
+
if !result.passed?
|
44
|
+
puts
|
28
45
|
puts
|
46
|
+
print_scenario
|
29
47
|
puts
|
30
|
-
puts colour.apply_to(result.exception.message.to_s)
|
31
|
-
|
48
|
+
puts indent(4, colour.apply_to(result.exception.message.to_s))
|
49
|
+
if result.failed?
|
50
|
+
puts indent(4, colour.apply_to(result.exception.backtrace.join("\n")))
|
51
|
+
end
|
32
52
|
end
|
33
53
|
puts
|
34
54
|
end
|
35
55
|
|
36
56
|
private
|
37
57
|
|
58
|
+
def print_scenario
|
59
|
+
@step_results.each do |step, result|
|
60
|
+
step.describe_source_to(StepsPrinter.new, result)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
38
64
|
def colour(result)
|
39
65
|
ResultColour.new(result).apply_to(result.to_s)
|
40
66
|
end
|
@@ -47,6 +73,27 @@ module BBC
|
|
47
73
|
end
|
48
74
|
end
|
49
75
|
|
76
|
+
class StepsPrinter
|
77
|
+
include ConsoleWriter
|
78
|
+
|
79
|
+
def before_hook(*)
|
80
|
+
end
|
81
|
+
|
82
|
+
def scenario(*)
|
83
|
+
end
|
84
|
+
|
85
|
+
def feature(*)
|
86
|
+
end
|
87
|
+
|
88
|
+
def after_hook(*)
|
89
|
+
end
|
90
|
+
|
91
|
+
def step(step, result)
|
92
|
+
colour = ResultColour.new(result)
|
93
|
+
puts indent(6, colour.apply_to("#{step.keyword}#{step.name}"))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
50
97
|
class ResultColour
|
51
98
|
def initialize(result)
|
52
99
|
@color = :white
|
@@ -87,8 +134,11 @@ module BBC
|
|
87
134
|
end
|
88
135
|
|
89
136
|
class CucumberRunner
|
137
|
+
include ConsoleWriter
|
138
|
+
|
90
139
|
def initialize(settings, cucumber_args)
|
91
140
|
@settings = settings
|
141
|
+
@cucumber_args = cucumber_args
|
92
142
|
end
|
93
143
|
|
94
144
|
def call
|
@@ -112,7 +162,7 @@ module BBC
|
|
112
162
|
@configuration = Cucumber::Cli::Configuration.new
|
113
163
|
# This is ugly, but until Cucumber offers a better API, we have to pass in our settings as though
|
114
164
|
# they were CLI arguments
|
115
|
-
@configuration.parse!([
|
165
|
+
@configuration.parse!(@cucumber_args + [
|
116
166
|
features_path,
|
117
167
|
"--format", "BBC::A11y::CucumberFormatter"])
|
118
168
|
@configuration
|
@@ -129,8 +179,7 @@ module BBC
|
|
129
179
|
def print_page_header(page_settings)
|
130
180
|
puts
|
131
181
|
puts
|
132
|
-
|
133
|
-
puts "=" * "BBC Accesibility: #{page_settings.url}".length
|
182
|
+
underline("BBC Accesibility: #{page_settings.url}")
|
134
183
|
end
|
135
184
|
|
136
185
|
end
|
@@ -9,17 +9,17 @@ method to define how to make this check.
|
|
9
9
|
|
10
10
|
In your .a11y.rb file, add the following code:
|
11
11
|
|
12
|
-
BBC::A11y.configure do
|
13
|
-
|
12
|
+
BBC::A11y.configure do
|
13
|
+
page "my_page.html" do
|
14
|
+
|
15
|
+
customize_world do
|
16
|
+
def assert_title_describes_primary_content_of_document(title, page)
|
17
|
+
# TODO: add your custom code here to make the check
|
18
|
+
end
|
19
|
+
end
|
14
20
|
|
15
|
-
customize_world do
|
16
|
-
def assert_title_describes_primary_content_of_document(title, page)
|
17
|
-
# TODO: add your custom code here to make the check
|
18
21
|
end
|
19
22
|
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
23
|
ERROR
|
24
24
|
end
|
25
25
|
end
|
data/lib/bbc/a11y/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.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.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Wynne
|
@@ -167,13 +167,16 @@ files:
|
|
167
167
|
- Rakefile
|
168
168
|
- bbc-a11y.gemspec
|
169
169
|
- bin/a11y
|
170
|
-
-
|
171
|
-
-
|
172
|
-
-
|
173
|
-
-
|
174
|
-
-
|
175
|
-
-
|
176
|
-
-
|
170
|
+
- examples/bbc-pages/.a11y.rb
|
171
|
+
- examples/bbc-pages/Gemfile
|
172
|
+
- examples/bbc-pages/Rakefile
|
173
|
+
- examples/local-web-app/.a11y.rb
|
174
|
+
- examples/local-web-app/Gemfile
|
175
|
+
- examples/local-web-app/Rakefile
|
176
|
+
- examples/local-web-app/config.ru
|
177
|
+
- examples/local-web-app/public/missing_header.html
|
178
|
+
- examples/local-web-app/public/perfect.html
|
179
|
+
- examples/local-web-app/readme.md
|
177
180
|
- features/01_core-purpose.md
|
178
181
|
- features/02_validation.feature
|
179
182
|
- features/03_javascript.feature
|
@@ -240,7 +243,7 @@ rubyforge_project:
|
|
240
243
|
rubygems_version: 2.4.5
|
241
244
|
signing_key:
|
242
245
|
specification_version: 4
|
243
|
-
summary: bbc-a11y-0.0.
|
246
|
+
summary: bbc-a11y-0.0.6
|
244
247
|
test_files:
|
245
248
|
- features/01_core-purpose.md
|
246
249
|
- features/02_validation.feature
|
data/example/Rakefile
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|