capybara-accessible 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +0 -2
- data/README.md +62 -48
- data/capybara-accessible.gemspec +3 -4
- data/lib/capybara/accessible/auditor.rb +8 -0
- data/lib/capybara/accessible/driver.rb +6 -2
- data/lib/capybara/accessible/element.rb +8 -3
- data/lib/capybara/accessible/version.rb +1 -1
- data/spec/driver_spec.rb +16 -5
- metadata +26 -42
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 01fb309e03c6d938d6ef7b42cb937ff39c61716f
|
4
|
+
data.tar.gz: c7d6487f9c68c51986ed954558529df1a6bfa0f3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 534b30513f7afe122e9c78f9e900e798830f798477dd202c4d823db5fbe0adb939a5b891ddd98680bc97c6675f82cb8bc2f649de62d3c6ab89091b765fe8d68d
|
7
|
+
data.tar.gz: f324fa20ecb8b46c9940175266bd532b58beaa49766bb821603931c923e17606bb52ff063a9d168e1d7a81f60fc614a515e604222dd98d8426b64b7618b02219
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,67 +1,58 @@
|
|
1
|
-
#
|
1
|
+
# capybara-accessible
|
2
2
|
|
3
|
-
|
3
|
+
## Automated accessibility testing in RSpec and Rails
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
capybara-accessible introduces accessibility tests into your [Rspec integration tests](https://www.relishapp.com/rspec/rspec-rails/docs/feature-specs/feature-spec),
|
6
|
+
helping you to capture existing failures and prevent future regressions.
|
7
7
|
|
8
|
-
|
8
|
+
It works by defining a custom webdriver that runs [Google's Accessibility Developer Tools](https://github.com/GoogleChrome/accessibility-developer-tools)
|
9
|
+
audits during each test run. Since the audits are invoked automatically on page load, you do not need to make explicit assertions on accessibility.
|
10
|
+
Instead, the test will simply fail with a message indicating the failures, like so:
|
11
|
+
|
12
|
+
![Error output from an Rspec failure](http://i.imgur.com/8RWEzzg.png)
|
13
|
+
|
14
|
+
Some of the audit rules that are included from Google's Accessibility Developer Tools:
|
9
15
|
* minimum color contrast
|
10
16
|
* label associations with inputs
|
11
17
|
* presence of alt attributes
|
12
18
|
* valid use of ARIA roles
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
capybara-accessible extends Capybara and defines a custom webdriver that runs javascript assertions on every page visit and link/button click.
|
17
|
-
This way you do not need to make explicit assertions on accessibility. Instead, the test will simply fail with a message indicating the accessibility errors, like so:
|
18
|
-
|
19
|
-
Failure/Error: visit '/inaccessible'
|
20
|
-
Capybara::Accessible::InaccessibleError:
|
21
|
-
*** Begin accessibility audit results ***
|
22
|
-
An accessibility audit found
|
23
|
-
Errors:
|
24
|
-
Error: AX_ARIA_01 (Elements with ARIA roles must use a valid, non-abstract ARIA role) failed on the following element:
|
25
|
-
body > .outer > .standup > .block.buttons
|
26
|
-
See https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules#AX_ARIA_01:_Elements_with_ARIA_roles_must_use_a_valid,_non-abstr for more information.
|
27
|
-
|
28
|
-
|
29
|
-
*** End accessibility audit results ***
|
20
|
+
See the [Google Accessibility Developer Tools wiki](https://code.google.com/p/accessibility-developer-tools/wiki/AuditRules)
|
21
|
+
for a full list of rules.
|
30
22
|
|
31
|
-
|
23
|
+
Visit the [capybara-accessible wiki](https://github.com/Casecommons/capybara-accessible/wiki) for background on why and how
|
24
|
+
we built capybara-accessible.
|
32
25
|
|
33
|
-
Visit the [wiki](https://github.com/Casecommons/capybara-accessible/wiki) for more background on automated accessibility testing with capybara-accessible.
|
34
26
|
|
35
27
|
## Installation
|
36
28
|
|
37
|
-
Add
|
29
|
+
Add `gem 'capybara-accessible'` to your application's Gemfile and run `bundle` on the command line.
|
38
30
|
|
39
|
-
gem 'capybara-accessible'
|
40
|
-
|
41
|
-
And then execute:
|
42
|
-
|
43
|
-
$ bundle
|
44
|
-
|
45
|
-
Or install it yourself as:
|
46
|
-
|
47
|
-
$ gem install capybara-accessible
|
48
31
|
|
49
32
|
## Usage
|
50
33
|
|
51
|
-
You can use capybara-accessible as a drop-in replacement for Rack::Test, Selenium or capybara-webkit drivers for Capybara.
|
34
|
+
You can use capybara-accessible as a drop-in replacement for Rack::Test, Selenium or capybara-webkit drivers for Capybara.
|
35
|
+
Simply set the driver in `spec/spec_helper.rb` or `features/support/env.rb`:
|
52
36
|
|
53
37
|
require 'capybara/rspec'
|
54
38
|
require 'capybara/accessible'
|
55
39
|
|
56
40
|
Capybara.default_driver = :accessible
|
41
|
+
Capybara.javascript_driver = :accessible
|
42
|
+
|
43
|
+
We suggest that you use [pry-rescue with pry-stack_explorer](https://github.com/ConradIrwin/pry-rescue)
|
44
|
+
to debug the accessibility failures in the DOM. pry-rescue will open a debugging session at the first exception,
|
45
|
+
pausing the driver so that you can inspect the page.
|
57
46
|
|
58
47
|
### Disabling audits
|
59
|
-
You can disable audits on individual tests by tagging the example or group
|
48
|
+
You can disable audits on individual tests by tagging the example or group with `inaccessible`.
|
49
|
+
|
50
|
+
#### Rspec
|
60
51
|
|
61
52
|
# spec/spec_helper.rb
|
62
53
|
|
63
54
|
RSpec.configure do |config|
|
64
|
-
config.around(:each, :
|
55
|
+
config.around(:each, inaccessible: true) do |example|
|
65
56
|
Capybara::Accessible.skip_audit { example.run }
|
66
57
|
end
|
67
58
|
end
|
@@ -69,20 +60,43 @@ You can disable audits on individual tests by tagging the example or group as `i
|
|
69
60
|
|
70
61
|
# spec/features/inaccessible_page_spec.rb
|
71
62
|
|
72
|
-
#
|
73
|
-
#
|
74
|
-
|
75
|
-
|
76
|
-
page.should have_css 'img'
|
63
|
+
# Page loads in examples tagged as inaccessible will not trigger an audit.
|
64
|
+
# All other assertions will be made.
|
65
|
+
feature '/inaccessible', inaccessible: true do
|
66
|
+
scenario 'displays an image' do
|
67
|
+
page.should have_css 'img' # this assertion will still be executed
|
77
68
|
end
|
78
69
|
end
|
79
70
|
|
80
|
-
|
71
|
+
#### Cucumber
|
72
|
+
|
73
|
+
# features/support/env.rb
|
74
|
+
|
75
|
+
Around('@inaccessible') do |scenario, block|
|
76
|
+
Capybara::Accessible.skip_audit { block.call }
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
# features/inaccessible_page.feature
|
81
|
+
|
82
|
+
# Page loads in examples tagged as inaccessible will not trigger an audit.
|
83
|
+
# All other assertions will be made.
|
84
|
+
@inaccessible
|
85
|
+
Scenario: Visiting a page that is inaccessible
|
86
|
+
When I visit a page that is inaccessible
|
87
|
+
Then I should see the inaccessible image # this assertion will still be executed
|
81
88
|
|
82
|
-
NOTE: axs_testing.js is automatically generated by Google's Accessibility Developer tools project. If you want to modify the audit rules, please contribute to the Google project: https://github.com/GoogleChrome/accessibility-developer-tools
|
83
89
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
90
|
+
## Support
|
91
|
+
|
92
|
+
If you think you've found a bug, or have installation questions or feature requests, please send a message
|
93
|
+
to the [mailing list](https://groups.google.com/forum/#!forum/capybara-accessible).
|
94
|
+
|
95
|
+
If you are commenting on the audit rules and failure messages, please check out the Google Accessibility Developer Tools
|
96
|
+
Project, and review their guidelines for reporting issues.
|
97
|
+
|
98
|
+
## Contributing
|
99
|
+
|
100
|
+
NOTE: axs_testing.js is a generated file from
|
101
|
+
[Google's Accessibility Developer Tools](https://github.com/GoogleChrome/accessibility-developer-tools).
|
102
|
+
If you'd like to contribute to the audit rules, please fork their Github project.
|
data/capybara-accessible.gemspec
CHANGED
@@ -15,14 +15,13 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
17
17
|
|
18
|
-
spec.
|
19
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.test_files = spec.files.grep(%r{^spec/})
|
20
19
|
spec.require_paths = ["lib"]
|
21
20
|
|
22
|
-
spec.add_dependency("capybara")
|
21
|
+
spec.add_dependency("capybara", "~> 2.0")
|
23
22
|
spec.add_dependency("selenium-webdriver")
|
24
23
|
|
25
|
-
spec.add_development_dependency "
|
24
|
+
spec.add_development_dependency "rake"
|
26
25
|
spec.add_development_dependency "rspec"
|
27
26
|
spec.add_development_dependency "pry"
|
28
27
|
spec.add_development_dependency "tddium"
|
@@ -19,6 +19,14 @@ module Capybara::Accessible
|
|
19
19
|
@@exclusions ||= []
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.log_level=(level)
|
23
|
+
@@log_level= level
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.log_level
|
27
|
+
@@log_level ||= :error
|
28
|
+
end
|
29
|
+
|
22
30
|
def audit_rules
|
23
31
|
File.read(File.expand_path("../../../vendor/google/accessibility-developer-tools/axs_testing.js", __FILE__))
|
24
32
|
end
|
@@ -4,8 +4,12 @@ module Capybara::Accessible
|
|
4
4
|
|
5
5
|
def visit(path)
|
6
6
|
super
|
7
|
-
if audit_failures.any?
|
8
|
-
|
7
|
+
if Capybara.current_driver == :accessible && audit_failures.any?
|
8
|
+
if Capybara::Accessible::Auditor.log_level == :warn
|
9
|
+
puts failure_messages
|
10
|
+
else
|
11
|
+
raise Capybara::Accessible::InaccessibleError, failure_messages
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
@@ -6,11 +6,16 @@ module Capybara
|
|
6
6
|
def click
|
7
7
|
synchronize { base.click }
|
8
8
|
begin
|
9
|
+
@session.driver.browser.switch_to.alert
|
10
|
+
puts "Skipping accessibility audit: Modal dialog present"
|
11
|
+
rescue ::Selenium::WebDriver::Error::NoAlertOpenError, ::NoMethodError
|
9
12
|
if Capybara.current_driver == :accessible && audit_failures.any?
|
10
|
-
|
13
|
+
if Capybara::Accessible::Auditor.log_level == :warn
|
14
|
+
puts failure_messages
|
15
|
+
else
|
16
|
+
raise Capybara::Accessible::InaccessibleError, failure_messages
|
17
|
+
end
|
11
18
|
end
|
12
|
-
rescue ::Selenium::WebDriver::Error::UnhandledAlertError => e
|
13
|
-
puts "Skipping accessibility audit: #{e}"
|
14
19
|
end
|
15
20
|
end
|
16
21
|
end
|
data/spec/driver_spec.rb
CHANGED
@@ -30,12 +30,23 @@ describe Capybara::Accessible::Driver do
|
|
30
30
|
expect { @session.visit('/excluded') }.to_not raise_error
|
31
31
|
end
|
32
32
|
end
|
33
|
-
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
context 'with log level set to warn' do
|
35
|
+
before do
|
36
|
+
Capybara::Accessible::Auditor.log_level = :warn
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'puts to stdout and does not raise an error' do
|
40
|
+
$stdout.should_receive(:puts)
|
41
|
+
expect { @session.visit('/inaccessible') }.to_not raise_error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'a page with a javascript popup' do
|
46
|
+
it 'does not raise an exception' do
|
47
|
+
@session.visit('/alert')
|
48
|
+
expect { @session.click_link('Alert!') }.to_not raise_error
|
49
|
+
end
|
39
50
|
end
|
40
51
|
end
|
41
52
|
end
|
metadata
CHANGED
@@ -1,126 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-accessible
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Case Commons
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-08-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: capybara
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
19
|
+
version: '2.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
26
|
+
version: '2.0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: selenium-webdriver
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
42
|
+
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
54
|
+
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: pry
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: tddium
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: sinatra
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
description: Capybara extension and webdriver for automated accessibility testing
|
@@ -151,27 +136,26 @@ files:
|
|
151
136
|
homepage: https://github.com/Casecommons/capybara-accessible
|
152
137
|
licenses:
|
153
138
|
- MIT
|
139
|
+
metadata: {}
|
154
140
|
post_install_message:
|
155
141
|
rdoc_options: []
|
156
142
|
require_paths:
|
157
143
|
- lib
|
158
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|
159
|
-
none: false
|
160
145
|
requirements:
|
161
|
-
- -
|
146
|
+
- - '>='
|
162
147
|
- !ruby/object:Gem::Version
|
163
148
|
version: '0'
|
164
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
-
none: false
|
166
150
|
requirements:
|
167
|
-
- -
|
151
|
+
- - '>='
|
168
152
|
- !ruby/object:Gem::Version
|
169
153
|
version: '0'
|
170
154
|
requirements: []
|
171
155
|
rubyforge_project:
|
172
|
-
rubygems_version:
|
156
|
+
rubygems_version: 2.0.3
|
173
157
|
signing_key:
|
174
|
-
specification_version:
|
158
|
+
specification_version: 4
|
175
159
|
summary: A Selenium based webdriver and Capybara extension that runs Google Accessibility
|
176
160
|
Developer Tools auditing assertions on page visits.
|
177
161
|
test_files:
|