bbc-a11y 0.0.5 → 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57852d504ecfb1f43c79ffd2aa4f351cff773313
4
- data.tar.gz: 2c3e3cb185c52bda5e4eea0dc7cb85e7f39dddad
3
+ metadata.gz: 02a747cee79f3519c0fc2124d6069462c8d3a567
4
+ data.tar.gz: 2206a476f841791cb74013b54f9403c3a3da39b9
5
5
  SHA512:
6
- metadata.gz: 6c804515aa01568b8c608f70ae4545d55e7bc110895f13beecd73aa97a0f00d42dc7b7badef4468260284c6635894b621c5722a8b085c153d9133774b79bdd27
7
- data.tar.gz: 99a9e4ef75d72731b778b0cad73e1d5a24b6534f819ead7a537363a9dde035f61d7e73161e961a8470ca79dfc093d189d0e23e35b46f4624f223ace610603625
6
+ metadata.gz: c4945eae8117e5e223ac27d834d23196646f7e31b730d958fd5345d8d5928b16816ae828563304f9b9c7b6dbd7dd7aaced3fa3e1726104cc2026592f35684f43
7
+ data.tar.gz: 5f45f2a0bcb880de8f87edbeee24fc99b60899ab092d26495457e20ff2a77b7a8fbfcdbe615ee993270b46a139e6a760adfa69cd994529be9ed375ed9a728744
data/README.md CHANGED
@@ -1,54 +1,60 @@
1
- # BBC Accessiblity Standards
1
+ #BBC Accessiblity Standards
2
2
 
3
- This tool runs a set of tests against a given URL to verify whether it meets the BBC accessibility standards.
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 use
5
+ ## How to install
6
6
 
7
- Run the `a11y` command, passing a URL:
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
- e.g.
10
+ ### Prerequisites
10
11
 
11
- a11y http://bbc.co.uk
12
+ [Install Ruby](https://www.ruby-lang.org/en/documentation/installation/) and then:
12
13
 
13
- You can also pass arguments to Cucumber (which is used internally) by separating the arguments with `--`. Everything
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
- a11y http://bbc.co.uk -- -t ~@manual
16
+ ### Adding a11y to your project's Gemfile
17
17
 
18
- ## How to install
18
+ Create or amend your your project's `Gemfile` to include this line:
19
19
 
20
- A11y is packaged as a Ruby gem, but is not yet available on the public Rubygems server. To install it, you'll need to either build it by hand, or add a reference to the github source in your Gemfile.
20
+ gem 'bbc-a11y`
21
21
 
22
- ### Prerequisites
22
+ Now install the gem:
23
23
 
24
- Install Ruby and `gem install bundler`.
24
+ bundle install
25
25
 
26
- ### Adding a11y to your project's Gemfile
26
+ ## Configuration
27
27
 
28
- Open your project's `Gemfile` and this line:
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
- gem 'bbc-a11y`, git: 'git@github.com:mattwynne/bbc-a11y.git'
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
- Now install the gem:
37
+ ### Skipping scenarios
33
38
 
34
- bundle install --binstubs
39
+ Nobody's perfect. Use `skip_scenario` in the configuration to opt-out of certain checks.
35
40
 
36
- *Note:* You'll need to make sure every user who wants to run `bundle install` (including your continuous integration environment) has at least read access to this Github project.
41
+ ```
42
+ BBC::A11y.configure do
43
+ page "http://bbc.co.uk" do
44
+ skip_scenario "W3C"
45
+ end
37
46
 
38
- ### Build and install the gem manually
47
+ page "http://bbc.co.uk/news"
48
+ end
49
+ ```
39
50
 
40
- This will install the `a11y` tool globally on your machine.
51
+ A11y will skip any scenarios from the specifications whose name contains that string.
41
52
 
42
- 1. Clone this repository
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
- 3. Install the gem
57
+ bundle exec a11y
51
58
 
52
- ~~~
53
- bundle exec rake install
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
@@ -8,5 +8,6 @@ task :unit do
8
8
  end
9
9
 
10
10
  task :acceptance do
11
- sh "cd example && rake"
11
+ sh "cd examples/local-web-app && rake"
12
+ sh "cd examples/bbc-pages && rake"
12
13
  end
@@ -0,0 +1,6 @@
1
+ BBC::A11y.configure do
2
+
3
+ page "http://bbc.co.uk/news"
4
+ page "http://bbc.co.uk/mundo"
5
+
6
+ end
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'bbc-a11y', path: '../..'
@@ -0,0 +1,3 @@
1
+ task :default do
2
+ sh "bundle exec ../../bin/a11y"
3
+ end
@@ -0,0 +1,3 @@
1
+ task :default do
2
+ sh "bundle exec ../../bin/a11y"
3
+ end
@@ -2,7 +2,7 @@ When(/^I visit the page$/) do
2
2
  browser.visit settings.url
3
3
  end
4
4
 
5
- When(/^I view the page with JavaScript and CSS disabled$/) do
5
+ When(/^I view the page with JavaScript disabled$/) do
6
6
  disable_javascript_and_css
7
7
  browser.visit settings.url
8
8
  end
@@ -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
- skip_this_scenario
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
 
@@ -1,5 +1,5 @@
1
1
  Before do |test_case|
2
2
  if settings.scenarios_to_skip.any? { |name| test_case.name.match name }
3
- skip_this_scenario
3
+ skip_this_scenario "Configured to be skipped"
4
4
  end
5
5
  end
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].join(' ')
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 url-to-test [-- cucumber-args]
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 "#{feature.name}"
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.failed? || result.pending? || result.skipped?
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
- puts colour.apply_to(result.exception.backtrace.join("\n"))
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
- puts "BBC Accesibility: #{page_settings.url}"
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
- page "my_page.html" do
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.5
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.5
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
- - example/.a11y.rb
171
- - example/Gemfile
172
- - example/Rakefile
173
- - example/config.ru
174
- - example/public/missing_header.html
175
- - example/public/perfect.html
176
- - example/readme.md
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.5
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
@@ -1,3 +0,0 @@
1
- task :default do
2
- sh "bundle exec ../bin/a11y"
3
- end
File without changes
File without changes
File without changes
File without changes