Skip to content

Commit 9d79457

Browse files
author
Cristina Muñoz
committed
Add axe depedency
Add test helper for a11y check
1 parent 758dc6c commit 9d79457

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ group :test do
105105
gem 'capybara-screenshot'
106106
gem 'launchy' # open up capybara screenshots automatically with `save_and_open_screenshot`
107107
gem 'webdrivers'
108+
gem 'axe-core-capybara'
109+
gem 'axe-core-api'
108110

109111
# Test coverage related libraries
110112
gem 'simplecov', require: false

Gemfile.lock

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@ GEM
8080
public_suffix (>= 2.0.2, < 6.0)
8181
afm (0.2.2)
8282
ast (2.4.2)
83+
axe-core-api (4.7.0)
84+
dumb_delegator
85+
virtus
86+
axe-core-capybara (4.7.0)
87+
axe-core-api
88+
dumb_delegator
89+
axiom-types (0.1.1)
90+
descendants_tracker (~> 0.0.4)
91+
ice_nine (~> 0.11.0)
92+
thread_safe (~> 0.3, >= 0.3.1)
8393
bcrypt (3.1.18)
8494
better_html (2.0.1)
8595
actionview (>= 6.0)
@@ -114,12 +124,16 @@ GEM
114124
capybara (>= 1.0, < 4)
115125
launchy
116126
coderay (1.1.3)
127+
coercible (1.0.0)
128+
descendants_tracker (~> 0.0.1)
117129
colorize (0.8.1)
118130
concurrent-ruby (1.2.2)
119131
crass (1.0.6)
120132
cssbundling-rails (1.1.2)
121133
railties (>= 6.0.0)
122134
date (3.3.3)
135+
descendants_tracker (0.0.4)
136+
thread_safe (~> 0.3, >= 0.3.1)
123137
devise (4.9.2)
124138
bcrypt (~> 3.0)
125139
orm_adapter (~> 0.1)
@@ -133,6 +147,7 @@ GEM
133147
dotenv-rails (2.8.1)
134148
dotenv (= 2.8.1)
135149
railties (>= 3.2)
150+
dumb_delegator (1.0.0)
136151
erubi (1.12.0)
137152
factory_bot (6.2.1)
138153
activesupport (>= 5.0.0)
@@ -171,6 +186,7 @@ GEM
171186
rails-i18n
172187
rainbow (>= 2.2.2, < 4.0)
173188
terminal-table (>= 1.5.1)
189+
ice_nine (0.11.2)
174190
jsbundling-rails (1.1.1)
175191
railties (>= 6.0.0)
176192
json (2.6.3)
@@ -395,6 +411,7 @@ GEM
395411
terminal-table (3.0.2)
396412
unicode-display_width (>= 1.1.1, < 3)
397413
thor (1.2.1)
414+
thread_safe (0.3.6)
398415
timecop (0.9.6)
399416
timeout (0.3.1)
400417
ttfunk (1.7.0)
@@ -409,6 +426,10 @@ GEM
409426
unicode-display_width (2.4.2)
410427
uniform_notifier (1.16.0)
411428
version_gem (1.1.1)
429+
virtus (2.0.0)
430+
axiom-types (~> 0.1)
431+
coercible (~> 1.0)
432+
descendants_tracker (~> 0.0, >= 0.0.3)
412433
warden (1.2.9)
413434
rack (>= 2.0.9)
414435
webdrivers (5.2.0)
@@ -432,6 +453,8 @@ PLATFORMS
432453
DEPENDENCIES
433454
activerecord-session_store
434455
acts_as_tenant (~> 0.5.0)
456+
axe-core-api
457+
axe-core-capybara
435458
bootsnap (>= 1.4.2)
436459
bootstrap_form (~> 4.5.0)
437460
bullet

test/integration/google_sso_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,9 @@ class GoogleSSOTest < ActionDispatch::IntegrationTest
2525

2626
assert has_content? 'Forgot your password?'
2727
end
28+
it 'sign in page is accessible' do
29+
visit root_path
30+
wait_for_element 'Sign in with Google'
31+
assert_accessible(page)
2832
end
2933
end

test/test_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
require 'omniauth_helper'
1111
require 'integration_helper'
1212
require 'rack/test'
13+
require 'axe-capybara'
14+
require 'axe-core'
1315

1416
# CI only
1517
if ENV['CI']
@@ -129,3 +131,8 @@ class ActionDispatch::IntegrationTest
129131

130132
# for controllers
131133
end
134+
135+
def assert_accessible(page, matcher = Axe::Matchers::BeAxeClean.new.according_to(:wcag21aa, 'best-practice'))
136+
audit_result = matcher.audit(page)
137+
assert(audit_result.passed?, audit_result.failure_message)
138+
end

0 commit comments

Comments
 (0)