rails_accessibility_testing 1.3.0 → 1.4.1
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 +4 -4
- data/CHANGELOG.md +21 -1
- data/GUIDES/getting_started.md +62 -12
- data/GUIDES/system_specs_for_accessibility.md +248 -0
- data/README.md +35 -2
- data/lib/rails_accessibility_testing/cli/command.rb +9 -1
- data/lib/rails_accessibility_testing/rspec_integration.rb +6 -5
- data/lib/rails_accessibility_testing/version.rb +1 -1
- data/lib/rails_accessibility_testing.rb +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bdfb13e559e3d6d786ac41d4027b1b89272b5595d2bc6b9324db3ee6082a8d90
|
|
4
|
+
data.tar.gz: b8b3420d7ba19cb20bb2a6b3601196e996e5e372aab780ec3de0a6ae7b44f22d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c2abe639249eca589eb405aeb0432b7fa57c45214c8de1b044c4fc1a5118c229ae16d90d04b7368ed3430830400ae77ef7a3848623edb587ec222a28b50f9376
|
|
7
|
+
data.tar.gz: ddc8a6f229e2038c080d923f0c9d25a21949543e581c8131b23c7e3536ffb633a9ee0ad855dce7d2bd2e9482a959a07f7171e021e08a7c5f5d831f0fb0994d1d
|
data/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,25 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [1.
|
|
8
|
+
## [1.4.1] - 2025-11-18
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Updated RubyGems homepage to point to GitHub Pages documentation site for better discoverability
|
|
12
|
+
- Users can now easily access comprehensive documentation directly from the RubyGems gem page
|
|
13
|
+
|
|
14
|
+
## [1.4.0] - 2025-11-18
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- Updated documentation examples to use clearer language ("runs accessibility checks" instead of "passes accessibility checks")
|
|
18
|
+
- Improved test descriptions to accurately reflect that tests will fail if accessibility issues are found
|
|
19
|
+
- Enhanced comments in examples to clarify when success messages appear
|
|
20
|
+
|
|
21
|
+
### Improved
|
|
22
|
+
- Better clarity in documentation about when accessibility checks pass vs fail
|
|
23
|
+
- More accurate test descriptions that don't imply tests will pass when they may fail
|
|
24
|
+
- Improved user understanding of accessibility check behavior
|
|
25
|
+
|
|
26
|
+
## [1.3.0] - 2025-11-18
|
|
9
27
|
|
|
10
28
|
### Added
|
|
11
29
|
- CLI reports now use ErrorMessageBuilder for detailed, formatted error messages
|
|
@@ -137,6 +155,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
137
155
|
- Compatible with RSpec Rails 6.0+
|
|
138
156
|
- Modular architecture with rule engine and check definitions
|
|
139
157
|
|
|
158
|
+
[1.4.1]: https://github.com/rayraycodes/rails-accessibility-testing/releases/tag/v1.4.1
|
|
159
|
+
[1.4.0]: https://github.com/rayraycodes/rails-accessibility-testing/releases/tag/v1.4.0
|
|
140
160
|
[1.3.0]: https://github.com/rayraycodes/rails-accessibility-testing/releases/tag/v1.3.0
|
|
141
161
|
[1.2.0]: https://github.com/rayraycodes/rails-accessibility-testing/releases/tag/v1.2.0
|
|
142
162
|
[1.1.6]: https://github.com/rayraycodes/rails-accessibility-testing/releases/tag/v1.1.6
|
data/GUIDES/getting_started.md
CHANGED
|
@@ -54,7 +54,7 @@ Let's see it in action. Create a simple system spec:
|
|
|
54
54
|
|
|
55
55
|
```ruby
|
|
56
56
|
# spec/system/home_spec.rb
|
|
57
|
-
RSpec.describe "Home Page" do
|
|
57
|
+
RSpec.describe "Home Page", type: :system do
|
|
58
58
|
it "displays the welcome message" do
|
|
59
59
|
visit root_path
|
|
60
60
|
expect(page).to have_content("Welcome")
|
|
@@ -63,6 +63,41 @@ RSpec.describe "Home Page" do
|
|
|
63
63
|
end
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
+
## Running Comprehensive Checks Explicitly
|
|
67
|
+
|
|
68
|
+
While checks run automatically after each `visit`, you can also run comprehensive checks explicitly at any point in your test:
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
# spec/system/home_page_accessibility_spec.rb
|
|
72
|
+
require 'rails_helper'
|
|
73
|
+
|
|
74
|
+
RSpec.describe 'Home Page Accessibility', type: :system do
|
|
75
|
+
it 'loads the page and runs comprehensive accessibility checks' do
|
|
76
|
+
visit root_path
|
|
77
|
+
expect(page).to have_content('Welcome')
|
|
78
|
+
|
|
79
|
+
# Run comprehensive accessibility checks explicitly
|
|
80
|
+
# This will fail the test if any accessibility issues are found
|
|
81
|
+
check_comprehensive_accessibility
|
|
82
|
+
# ✅ This runs all 11 comprehensive checks:
|
|
83
|
+
# - Form labels, Image alt text, Interactive elements
|
|
84
|
+
# - Heading hierarchy, Keyboard accessibility, ARIA landmarks
|
|
85
|
+
# - Form errors, Table structure, Duplicate IDs
|
|
86
|
+
# - Skip links, Color contrast (if enabled)
|
|
87
|
+
# If all checks pass, you'll see: "All comprehensive accessibility checks passed! (11 checks)"
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**When to use explicit checks:**
|
|
93
|
+
- When you want to run checks at a specific point in your test (e.g., after filling a form)
|
|
94
|
+
- When you want to ensure checks run even if the test might fail before the automatic check
|
|
95
|
+
- When you want to test multiple pages in one spec and check each one explicitly
|
|
96
|
+
|
|
97
|
+
**Note:** Even if you call `check_comprehensive_accessibility` explicitly, the automatic checks will still run after the test completes (unless the test fails before reaching the explicit check).
|
|
98
|
+
|
|
99
|
+
### Example: Comprehensive Check Output
|
|
100
|
+
|
|
66
101
|
If there are accessibility issues, you'll see detailed error messages like:
|
|
67
102
|
|
|
68
103
|
```
|
|
@@ -96,19 +131,33 @@ If there are accessibility issues, you'll see detailed error messages like:
|
|
|
96
131
|
|
|
97
132
|
## Understanding the Checks
|
|
98
133
|
|
|
99
|
-
Rails A11y runs 11 comprehensive checks:
|
|
134
|
+
Rails A11y runs **11 comprehensive checks** automatically. These checks are WCAG 2.1 AA aligned:
|
|
100
135
|
|
|
101
|
-
1. **Form Labels** - All inputs have associated labels
|
|
102
|
-
2. **Image Alt Text** - All images have alt attributes
|
|
103
|
-
3. **Interactive Elements** - Buttons and
|
|
104
|
-
4. **Heading Hierarchy** - Proper h1-h6 structure
|
|
136
|
+
1. **Form Labels** - All form inputs have associated labels
|
|
137
|
+
2. **Image Alt Text** - All images have descriptive alt attributes (including empty alt="" detection)
|
|
138
|
+
3. **Interactive Elements** - Buttons, links, and other interactive elements have accessible names
|
|
139
|
+
4. **Heading Hierarchy** - Proper h1-h6 structure without skipping levels
|
|
105
140
|
5. **Keyboard Accessibility** - All interactive elements are keyboard accessible
|
|
106
|
-
6. **ARIA Landmarks** - Proper use of ARIA landmark roles
|
|
107
|
-
7. **Form Error Associations** -
|
|
108
|
-
8. **Table Structure** - Tables have proper headers
|
|
109
|
-
9. **Duplicate IDs** - No duplicate ID attributes
|
|
110
|
-
10. **Skip Links** - Skip navigation links present
|
|
111
|
-
11. **Color Contrast** - Text meets contrast requirements (optional)
|
|
141
|
+
6. **ARIA Landmarks** - Proper use of ARIA landmark roles for page structure
|
|
142
|
+
7. **Form Error Associations** - Form errors are properly linked to their form fields
|
|
143
|
+
8. **Table Structure** - Tables have proper headers and structure
|
|
144
|
+
9. **Duplicate IDs** - No duplicate ID attributes on the page
|
|
145
|
+
10. **Skip Links** - Skip navigation links are present for keyboard users
|
|
146
|
+
11. **Color Contrast** - Text meets WCAG contrast requirements (optional, disabled by default for performance)
|
|
147
|
+
|
|
148
|
+
### What `check_comprehensive_accessibility` Does
|
|
149
|
+
|
|
150
|
+
When you call `check_comprehensive_accessibility`, it runs all 11 checks above and provides detailed error messages for any violations found. Each error includes:
|
|
151
|
+
|
|
152
|
+
- **File location hints** - Know exactly which view file to fix
|
|
153
|
+
- **Element details** - Tag, ID, classes, and visible text
|
|
154
|
+
- **Actionable fix instructions** - Code examples showing how to fix the issue
|
|
155
|
+
- **WCAG references** - Links to relevant WCAG guidelines
|
|
156
|
+
|
|
157
|
+
If all checks pass, you'll see:
|
|
158
|
+
```
|
|
159
|
+
✅ All comprehensive accessibility checks passed! (11 checks)
|
|
160
|
+
```
|
|
112
161
|
|
|
113
162
|
## Configuration
|
|
114
163
|
|
|
@@ -171,6 +220,7 @@ end
|
|
|
171
220
|
|
|
172
221
|
## Next Steps
|
|
173
222
|
|
|
223
|
+
- **⭐ Read the [System Specs Guide](system_specs_for_accessibility.md)** - Recommended approach for reliable accessibility testing
|
|
174
224
|
- **Read the [CI Integration Guide](continuous_integration.md)** to set up automated checks
|
|
175
225
|
- **Check out [Writing Accessible Views](writing_accessible_views_in_rails.md)** for best practices
|
|
176
226
|
- **See [Working with Designers](working_with_designers_and_content_authors.md)** for team collaboration
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# Using System Specs for Accessibility Testing
|
|
2
|
+
|
|
3
|
+
System specs are the **recommended and most reliable** way to run accessibility checks in your Rails application. This guide shows you how to set up continuous accessibility testing using RSpec system specs.
|
|
4
|
+
|
|
5
|
+
## Why System Specs?
|
|
6
|
+
|
|
7
|
+
✅ **More Reliable** - Runs in the same test environment as your other specs
|
|
8
|
+
✅ **Faster** - No need to wait for external server processes
|
|
9
|
+
✅ **Better Integration** - Works seamlessly with your existing test suite
|
|
10
|
+
✅ **Automatic** - Checks run automatically after each `visit` in system specs
|
|
11
|
+
✅ **Clear Feedback** - Detailed error messages with file locations and fix instructions
|
|
12
|
+
|
|
13
|
+
## Quick Setup
|
|
14
|
+
|
|
15
|
+
### 1. Create System Specs
|
|
16
|
+
|
|
17
|
+
Create system specs for the pages you want to test. Name them with `_accessibility_spec.rb` suffix for clarity:
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
# spec/system/home_page_accessibility_spec.rb
|
|
21
|
+
require 'rails_helper'
|
|
22
|
+
|
|
23
|
+
RSpec.describe 'Home Page Accessibility', type: :system do
|
|
24
|
+
it 'loads the page and runs comprehensive accessibility checks' do
|
|
25
|
+
visit root_path
|
|
26
|
+
expect(page).to have_content('Biorepository').or have_content('Welcome')
|
|
27
|
+
|
|
28
|
+
# Run comprehensive accessibility checks
|
|
29
|
+
# This will fail the test if any accessibility issues are found
|
|
30
|
+
check_comprehensive_accessibility
|
|
31
|
+
# ✅ If all checks pass, you'll see: "All comprehensive accessibility checks passed! (11 checks)"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Automatic Checks
|
|
37
|
+
|
|
38
|
+
The gem automatically runs comprehensive accessibility checks after each `visit` in system specs. You don't need to call `check_comprehensive_accessibility` manually unless you want to run checks at a specific point in your test.
|
|
39
|
+
|
|
40
|
+
### 3. Add to Procfile.dev (Optional)
|
|
41
|
+
|
|
42
|
+
For continuous testing during development, add to your `Procfile.dev`:
|
|
43
|
+
|
|
44
|
+
```ruby
|
|
45
|
+
web: $(bundle show rails_accessibility_testing)/exe/rails_server_safe
|
|
46
|
+
css: bin/rails dartsass:watch
|
|
47
|
+
a11y: while true; do bundle exec rspec spec/system/*_accessibility_spec.rb; sleep 30; done
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This will run your accessibility specs every 30 seconds while you develop.
|
|
51
|
+
|
|
52
|
+
## Example Specs
|
|
53
|
+
|
|
54
|
+
### Basic Page Check
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
# spec/system/home_page_accessibility_spec.rb
|
|
58
|
+
require 'rails_helper'
|
|
59
|
+
|
|
60
|
+
RSpec.describe 'Home Page Accessibility', type: :system do
|
|
61
|
+
it 'runs accessibility checks on the home page' do
|
|
62
|
+
visit root_path
|
|
63
|
+
# ✅ Comprehensive accessibility checks run automatically after this test!
|
|
64
|
+
# The test will fail if any accessibility issues are found
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Multiple Pages
|
|
70
|
+
|
|
71
|
+
```ruby
|
|
72
|
+
# spec/system/pages_accessibility_spec.rb
|
|
73
|
+
require 'rails_helper'
|
|
74
|
+
|
|
75
|
+
RSpec.describe 'Pages Accessibility', type: :system do
|
|
76
|
+
it 'runs accessibility checks on home page' do
|
|
77
|
+
visit root_path
|
|
78
|
+
# Checks run automatically - test fails if issues found
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'runs accessibility checks on about page' do
|
|
82
|
+
visit about_path
|
|
83
|
+
# Checks run automatically - test fails if issues found
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'runs accessibility checks on contact page' do
|
|
87
|
+
visit contact_path
|
|
88
|
+
# Checks run automatically - test fails if issues found
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### With User Authentication
|
|
94
|
+
|
|
95
|
+
```ruby
|
|
96
|
+
# spec/system/dashboard_accessibility_spec.rb
|
|
97
|
+
require 'rails_helper'
|
|
98
|
+
|
|
99
|
+
RSpec.describe 'Dashboard Accessibility', type: :system do
|
|
100
|
+
before do
|
|
101
|
+
user = FactoryBot.create(:user)
|
|
102
|
+
sign_in user
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
it 'runs accessibility checks on dashboard' do
|
|
106
|
+
visit dashboard_path
|
|
107
|
+
# ✅ Comprehensive accessibility checks run automatically after authentication!
|
|
108
|
+
# The test will fail if any accessibility issues are found
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Skip Checks for Specific Tests
|
|
114
|
+
|
|
115
|
+
```ruby
|
|
116
|
+
it 'does something without accessibility checks', skip_a11y: true do
|
|
117
|
+
visit some_path
|
|
118
|
+
# Accessibility checks won't run for this test
|
|
119
|
+
end
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## What Gets Checked
|
|
123
|
+
|
|
124
|
+
The gem automatically runs **11 comprehensive accessibility checks**:
|
|
125
|
+
|
|
126
|
+
1. ✅ **Form Labels** - All form inputs have associated labels
|
|
127
|
+
2. ✅ **Image Alt Text** - All images have descriptive alt attributes
|
|
128
|
+
3. ✅ **Interactive Elements** - Buttons, links have accessible names
|
|
129
|
+
4. ✅ **Heading Hierarchy** - Proper h1-h6 structure
|
|
130
|
+
5. ✅ **Keyboard Accessibility** - All interactive elements keyboard accessible
|
|
131
|
+
6. ✅ **ARIA Landmarks** - Proper use of ARIA landmark roles
|
|
132
|
+
7. ✅ **Form Error Associations** - Errors linked to form fields
|
|
133
|
+
8. ✅ **Table Structure** - Tables have proper headers
|
|
134
|
+
9. ✅ **Duplicate IDs** - No duplicate ID attributes
|
|
135
|
+
10. ✅ **Skip Links** - Skip navigation links present
|
|
136
|
+
11. ✅ **Color Contrast** - Text meets contrast requirements (optional, disabled by default)
|
|
137
|
+
|
|
138
|
+
## Success Messages
|
|
139
|
+
|
|
140
|
+
When all checks pass, you'll see:
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
✅ All comprehensive accessibility checks passed! (11 checks)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Error Messages
|
|
147
|
+
|
|
148
|
+
When issues are found, you get detailed, actionable errors:
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
======================================================================
|
|
152
|
+
❌ ACCESSIBILITY ERROR: Page missing H1 heading
|
|
153
|
+
======================================================================
|
|
154
|
+
|
|
155
|
+
📄 Page Being Tested:
|
|
156
|
+
URL: http://127.0.0.1:54384/
|
|
157
|
+
Path: /
|
|
158
|
+
📝 Likely View File: app/views/home/about.html.erb
|
|
159
|
+
|
|
160
|
+
📍 Element Details:
|
|
161
|
+
Tag: <page>
|
|
162
|
+
ID: (none)
|
|
163
|
+
Classes: (none)
|
|
164
|
+
Visible text: Page has no H1 heading
|
|
165
|
+
|
|
166
|
+
🔧 HOW TO FIX:
|
|
167
|
+
Add an <h1> heading to your page:
|
|
168
|
+
|
|
169
|
+
<h1>Main Page Title</h1>
|
|
170
|
+
|
|
171
|
+
Or in Rails ERB:
|
|
172
|
+
<h1><%= @page_title || 'Default Title' %></h1>
|
|
173
|
+
|
|
174
|
+
💡 Best Practice: Every page should have exactly one <h1>.
|
|
175
|
+
It should describe the main purpose of the page.
|
|
176
|
+
|
|
177
|
+
📖 WCAG Reference: https://www.w3.org/WAI/WCAG21/Understanding/
|
|
178
|
+
======================================================================
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Running Specs
|
|
182
|
+
|
|
183
|
+
### Run All Accessibility Specs
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
bundle exec rspec spec/system/*_accessibility_spec.rb
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Run Specific Spec
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
bundle exec rspec spec/system/home_page_accessibility_spec.rb
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Run with Documentation Format
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
bundle exec rspec spec/system/*_accessibility_spec.rb --format documentation
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Continuous Integration
|
|
202
|
+
|
|
203
|
+
Add to your CI configuration:
|
|
204
|
+
|
|
205
|
+
```yaml
|
|
206
|
+
# .github/workflows/ci.yml
|
|
207
|
+
- name: Run Accessibility Tests
|
|
208
|
+
run: bundle exec rspec spec/system/*_accessibility_spec.rb
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Best Practices
|
|
212
|
+
|
|
213
|
+
1. **Name your specs clearly** - Use `_accessibility_spec.rb` suffix
|
|
214
|
+
2. **Test critical paths** - Focus on user-facing pages
|
|
215
|
+
3. **Keep specs simple** - One page per spec is often enough
|
|
216
|
+
4. **Use Procfile.dev** - For continuous testing during development
|
|
217
|
+
5. **Run in CI** - Catch issues before they reach production
|
|
218
|
+
|
|
219
|
+
## Troubleshooting
|
|
220
|
+
|
|
221
|
+
### Checks Not Running
|
|
222
|
+
|
|
223
|
+
Make sure:
|
|
224
|
+
- Your spec has `type: :system`
|
|
225
|
+
- You call `visit` in your test
|
|
226
|
+
- The gem is properly configured in `spec/rails_helper.rb`
|
|
227
|
+
|
|
228
|
+
### Success Message Not Showing
|
|
229
|
+
|
|
230
|
+
The success message appears when all checks pass. If you don't see it, there may be silent failures. Check your RSpec output for any exceptions.
|
|
231
|
+
|
|
232
|
+
### Slow Tests
|
|
233
|
+
|
|
234
|
+
Disable color contrast checking in development:
|
|
235
|
+
|
|
236
|
+
```yaml
|
|
237
|
+
# config/accessibility.yml
|
|
238
|
+
development:
|
|
239
|
+
checks:
|
|
240
|
+
color_contrast: false
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Next Steps
|
|
244
|
+
|
|
245
|
+
- See [Getting Started Guide](getting_started.md) for initial setup
|
|
246
|
+
- See [Continuous Integration Guide](continuous_integration.md) for CI/CD setup
|
|
247
|
+
- See [Writing Accessible Views](writing_accessible_views_in_rails.md) for best practices
|
|
248
|
+
|
data/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
**The RSpec + RuboCop of accessibility for Rails. Catch WCAG violations before they reach production.**
|
|
9
9
|
|
|
10
|
-
**Current Version:** 1.
|
|
10
|
+
**Current Version:** 1.4.1
|
|
11
11
|
|
|
12
12
|
📖 **[📚 Full Documentation](https://rayraycodes.github.io/rails-accessibility-testing/)** | [💻 GitHub](https://github.com/rayraycodes/rails-accessibility-testing) | [💎 RubyGems](https://rubygems.org/gems/rails_accessibility_testing)
|
|
13
13
|
|
|
@@ -84,13 +84,45 @@ RailsAccessibilityTesting::Integration::MinitestIntegration.setup!
|
|
|
84
84
|
|
|
85
85
|
## 📖 Usage
|
|
86
86
|
|
|
87
|
+
### System Specs (Recommended)
|
|
88
|
+
|
|
89
|
+
**System specs are the recommended and most reliable way to run accessibility checks.** They're faster, more reliable, and integrate seamlessly with your test suite.
|
|
90
|
+
|
|
91
|
+
Create system specs for your pages:
|
|
92
|
+
|
|
93
|
+
```ruby
|
|
94
|
+
# spec/system/home_page_accessibility_spec.rb
|
|
95
|
+
require 'rails_helper'
|
|
96
|
+
|
|
97
|
+
RSpec.describe 'Home Page Accessibility', type: :system do
|
|
98
|
+
it 'loads successfully and passes comprehensive accessibility checks' do
|
|
99
|
+
visit root_path
|
|
100
|
+
expect(page).to have_content('Biorepository').or have_content('Welcome')
|
|
101
|
+
|
|
102
|
+
# Run comprehensive accessibility checks
|
|
103
|
+
check_comprehensive_accessibility
|
|
104
|
+
# ✅ Comprehensive accessibility checks (11 checks) also run automatically after this test!
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Accessibility checks run automatically after each `visit` in system specs!**
|
|
110
|
+
|
|
111
|
+
For continuous testing during development, add to your `Procfile.dev`:
|
|
112
|
+
|
|
113
|
+
```ruby
|
|
114
|
+
a11y: while true; do bundle exec rspec spec/system/*_accessibility_spec.rb; sleep 30; done
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
📖 **[See the full System Specs Guide](GUIDES/system_specs_for_accessibility.md)** for detailed examples and best practices.
|
|
118
|
+
|
|
87
119
|
### Automatic Checks
|
|
88
120
|
|
|
89
121
|
Just write your specs normally - checks run automatically:
|
|
90
122
|
|
|
91
123
|
```ruby
|
|
92
124
|
# spec/system/home_page_spec.rb
|
|
93
|
-
RSpec.describe "Home Page" do
|
|
125
|
+
RSpec.describe "Home Page", type: :system do
|
|
94
126
|
it "displays welcome message" do
|
|
95
127
|
visit root_path
|
|
96
128
|
expect(page).to have_content("Welcome")
|
|
@@ -270,6 +302,7 @@ Complete documentation site with all guides, examples, and API reference. The do
|
|
|
270
302
|
|
|
271
303
|
### Guides
|
|
272
304
|
|
|
305
|
+
- **[System Specs for Accessibility](GUIDES/system_specs_for_accessibility.md)** - ⭐ **Recommended approach** - Using system specs for reliable accessibility testing
|
|
273
306
|
- **[Getting Started](GUIDES/getting_started.md)** - Quick start guide
|
|
274
307
|
- **[Continuous Integration](GUIDES/continuous_integration.md)** - CI/CD setup
|
|
275
308
|
- **[Writing Accessible Views](GUIDES/writing_accessible_views_in_rails.md)** - Best practices
|
|
@@ -106,6 +106,9 @@ module RailsAccessibilityTesting
|
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
def run_checks(options, config)
|
|
109
|
+
# Reset wait attempts counter for each run
|
|
110
|
+
@wait_attempts = 0
|
|
111
|
+
|
|
109
112
|
require 'capybara'
|
|
110
113
|
require 'capybara/dsl'
|
|
111
114
|
require 'selenium-webdriver'
|
|
@@ -160,7 +163,12 @@ module RailsAccessibilityTesting
|
|
|
160
163
|
# If still not ready, skip this check and try next time
|
|
161
164
|
unless server_ready
|
|
162
165
|
# Server still starting - this is normal, will retry automatically
|
|
163
|
-
|
|
166
|
+
# Only show message occasionally to avoid spam (every 3rd attempt)
|
|
167
|
+
@wait_attempts ||= 0
|
|
168
|
+
@wait_attempts += 1
|
|
169
|
+
if @wait_attempts % 3 == 1
|
|
170
|
+
$stderr.puts "Waiting for server to start... (will retry automatically)"
|
|
171
|
+
end
|
|
164
172
|
next
|
|
165
173
|
end
|
|
166
174
|
end
|
|
@@ -49,12 +49,13 @@ module RailsAccessibilityTesting
|
|
|
49
49
|
instance = example.example_group_instance
|
|
50
50
|
instance.check_comprehensive_accessibility
|
|
51
51
|
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
# If we get here without an exception, all checks passed
|
|
53
|
+
# Note: check_comprehensive_accessibility will raise if there are errors,
|
|
54
|
+
# so if we reach this point, checks passed successfully
|
|
55
|
+
$stdout.puts "\n✅ All comprehensive accessibility checks passed! (11 checks)"
|
|
56
|
+
$stdout.flush
|
|
57
57
|
rescue StandardError => e
|
|
58
|
+
# Accessibility check failed - set the exception so test fails
|
|
58
59
|
example.set_exception(e)
|
|
59
60
|
end
|
|
60
61
|
end
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# Automatically configures accessibility testing for Rails system specs with
|
|
6
6
|
# comprehensive checks and detailed error messages.
|
|
7
7
|
#
|
|
8
|
-
# @version 1.1
|
|
8
|
+
# @version 1.4.1
|
|
9
9
|
# @author Regan Maharjan
|
|
10
10
|
#
|
|
11
11
|
# @example Basic usage
|
|
@@ -38,7 +38,7 @@ begin
|
|
|
38
38
|
require_relative 'rails_accessibility_testing/version'
|
|
39
39
|
rescue LoadError
|
|
40
40
|
module RailsAccessibilityTesting
|
|
41
|
-
VERSION = '1.
|
|
41
|
+
VERSION = '1.4.1'
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_accessibility_testing
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Regan Maharjan
|
|
@@ -84,6 +84,7 @@ files:
|
|
|
84
84
|
- CONTRIBUTING.md
|
|
85
85
|
- GUIDES/continuous_integration.md
|
|
86
86
|
- GUIDES/getting_started.md
|
|
87
|
+
- GUIDES/system_specs_for_accessibility.md
|
|
87
88
|
- GUIDES/working_with_designers_and_content_authors.md
|
|
88
89
|
- GUIDES/writing_accessible_views_in_rails.md
|
|
89
90
|
- LICENSE
|
|
@@ -130,11 +131,11 @@ files:
|
|
|
130
131
|
- lib/rails_accessibility_testing/shared_examples.rb
|
|
131
132
|
- lib/rails_accessibility_testing/version.rb
|
|
132
133
|
- lib/tasks/accessibility.rake
|
|
133
|
-
homepage: https://github.
|
|
134
|
+
homepage: https://rayraycodes.github.io/rails-accessibility-testing/
|
|
134
135
|
licenses:
|
|
135
136
|
- MIT
|
|
136
137
|
metadata:
|
|
137
|
-
homepage_uri: https://github.
|
|
138
|
+
homepage_uri: https://rayraycodes.github.io/rails-accessibility-testing/
|
|
138
139
|
source_code_uri: https://github.com/rayraycodes/rails-accessibility-testing
|
|
139
140
|
changelog_uri: https://github.com/rayraycodes/rails-accessibility-testing/blob/main/CHANGELOG.md
|
|
140
141
|
documentation_uri: https://rayraycodes.github.io/rails-accessibility-testing/
|