rails_accessibility_testing 1.6.0 → 1.7.0
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 +17 -0
- data/GUIDES/best_practices.md +261 -0
- data/GUIDES/continuous_integration.md +1 -0
- data/README.md +1 -0
- data/lib/generators/rails_a11y/install/install_generator.rb +6 -2
- data/lib/generators/rails_a11y/install/templates/accessibility.yml.erb +6 -3
- data/lib/generators/rails_a11y/install/templates/all_pages_accessibility_spec.rb.erb +36 -65
- data/lib/generators/rails_a11y/install/templates/initializer.rb.erb +10 -7
- data/lib/rails_accessibility_testing/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 61344dc6a53b7678ea457fdfca0237fb7dfece5ef7825aaf0449fea1d187737d
|
|
4
|
+
data.tar.gz: c843795ff4c676607b4fde8d207a7055db5a9b128054583964843a6d41cc6ece
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c9e66513f4b0d427e8ae5d1dbd91d4aa1da7d6758d71993ce54cd8a1e083e241c297d76ea15dde99adab4b345165fd22d7ab7d070124fdd123dfa42eccaca049
|
|
7
|
+
data.tar.gz: 4b4a86455dd1e46c4f4b08c4edae141d49f533be9dd3ce86971a52ea4eb7e203b3a0c23e5730c78e04be31d36b0cfb315011201e479049302e9843e1655d74c3
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ 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
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [1.7.0] - 2026-02-11
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- **Generator Templates Updated**: Improved default configuration based on production best practices
|
|
14
|
+
- `accessibility.yml`: Changed `accessibility_enabled` default from `true` to `false` with detailed CI/CD documentation
|
|
15
|
+
- `rails_a11y.rb`: Added production safety guard (`if defined?(RailsAccessibilityTesting)`) and set `auto_run_checks = false` by default
|
|
16
|
+
- `all_pages_accessibility_spec.rb`: Changed RSpec type from `:system` to `:accessibility` and improved error formatting with unified helper method
|
|
17
|
+
- Updated documentation URLs to correct GitHub Pages link
|
|
18
|
+
- Generator now creates `spec/accessibility/` directory instead of `spec/system/` for better organization
|
|
19
|
+
- **Best Practices Guide**: Added comprehensive [Best Practices guide](GUIDES/best_practices.md) documenting production-tested configuration patterns
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- **[Best Practices Guide](GUIDES/best_practices.md)**: New guide documenting recommended configuration patterns based on real-world production usage, including CI/CD safety, production guards, and improved error formatting
|
|
23
|
+
- **Template Updates Summary**: Added `TEMPLATE_UPDATES_SUMMARY.md` documenting all template improvements
|
|
24
|
+
|
|
8
25
|
## [1.6.0] - 2024-12-XX
|
|
9
26
|
|
|
10
27
|
### Added
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# Best Practices for Rails Accessibility Testing
|
|
2
|
+
|
|
3
|
+
This guide documents recommended practices for configuring and using Rails Accessibility Testing in your Rails application, based on real-world usage and production experience.
|
|
4
|
+
|
|
5
|
+
## Configuration Best Practices
|
|
6
|
+
|
|
7
|
+
### 1. Disable by Default for CI/CD Safety
|
|
8
|
+
|
|
9
|
+
**Recommended:** Set `accessibility_enabled: false` in `config/accessibility.yml`
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
# config/accessibility.yml
|
|
13
|
+
accessibility_enabled: false
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Why?**
|
|
17
|
+
- Prevents accessibility test failures from blocking your entire CI/CD pipeline
|
|
18
|
+
- Allows other RSpec tests to pass even if accessibility tests fail
|
|
19
|
+
- Gives you control over when to run accessibility checks
|
|
20
|
+
- Enables manual testing: `rspec spec/accessibility/all_pages_accessibility_spec.rb`
|
|
21
|
+
|
|
22
|
+
**When to enable:**
|
|
23
|
+
- Set to `true` when you want accessibility tests to run automatically
|
|
24
|
+
- Use manual invocation for focused accessibility testing
|
|
25
|
+
- Enable in CI only when you're ready to enforce accessibility compliance
|
|
26
|
+
|
|
27
|
+
**Example:**
|
|
28
|
+
```yaml
|
|
29
|
+
# Default: false
|
|
30
|
+
# (Set to false to allow other RSpec tests to pass in GitHub Actions CI even if accessibility tests fail.
|
|
31
|
+
# When true, any failing accessibility tests will cause the entire CI pipeline to fail.)
|
|
32
|
+
# Set to true to run accessibility checks manually: rspec spec/accessibility/all_pages_accessibility_spec.rb
|
|
33
|
+
accessibility_enabled: false
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Production Safety Guard
|
|
37
|
+
|
|
38
|
+
**Recommended:** Wrap configuration in conditional check
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
# config/initializers/rails_a11y.rb
|
|
42
|
+
if defined?(RailsAccessibilityTesting)
|
|
43
|
+
RailsAccessibilityTesting.configure do |config|
|
|
44
|
+
config.auto_run_checks = false
|
|
45
|
+
# ... other config
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Why?**
|
|
51
|
+
- Prevents errors if gem is not available in production
|
|
52
|
+
- Allows gem to be excluded from production bundle
|
|
53
|
+
- Safe deployment even if gem configuration is present
|
|
54
|
+
|
|
55
|
+
### 3. Manual Control Over Automatic Checks
|
|
56
|
+
|
|
57
|
+
**Recommended:** Set `auto_run_checks = false` in initializer
|
|
58
|
+
|
|
59
|
+
```ruby
|
|
60
|
+
config.auto_run_checks = false
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Why?**
|
|
64
|
+
- Gives developers explicit control over when checks run
|
|
65
|
+
- Prevents unexpected test failures during development
|
|
66
|
+
- Allows focused accessibility testing when needed
|
|
67
|
+
- Use `check_comprehensive_accessibility` explicitly in specs when desired
|
|
68
|
+
|
|
69
|
+
**Alternative:** Enable per-environment
|
|
70
|
+
```ruby
|
|
71
|
+
config.auto_run_checks = Rails.env.development? || Rails.env.test?
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 4. Use Accessibility-Specific RSpec Type
|
|
75
|
+
|
|
76
|
+
**Recommended:** Use `type: :accessibility` for accessibility specs
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
RSpec.describe 'All Pages Accessibility', type: :accessibility do
|
|
80
|
+
# ...
|
|
81
|
+
end
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Why?**
|
|
85
|
+
- Proper RSpec integration with accessibility helpers
|
|
86
|
+
- Better test organization and filtering
|
|
87
|
+
- Clearer intent in test files
|
|
88
|
+
|
|
89
|
+
### 5. Improved Error Formatting
|
|
90
|
+
|
|
91
|
+
**Recommended:** Use unified formatting method for better output
|
|
92
|
+
|
|
93
|
+
The generator now creates a `format_issues_by_file` helper method that:
|
|
94
|
+
- Groups errors and warnings by file
|
|
95
|
+
- Shows errors first, then warnings
|
|
96
|
+
- Provides better structure and readability
|
|
97
|
+
- Uses proper test assertions (`expect(errors).to be_empty`)
|
|
98
|
+
|
|
99
|
+
## CI/CD Integration Best Practices
|
|
100
|
+
|
|
101
|
+
### GitHub Actions
|
|
102
|
+
|
|
103
|
+
**Recommended approach:**
|
|
104
|
+
|
|
105
|
+
1. **Keep accessibility disabled by default:**
|
|
106
|
+
```yaml
|
|
107
|
+
# config/accessibility.yml
|
|
108
|
+
accessibility_enabled: false
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
2. **Run accessibility tests separately:**
|
|
112
|
+
```yaml
|
|
113
|
+
# .github/workflows/accessibility.yml
|
|
114
|
+
- name: Run accessibility tests
|
|
115
|
+
run: |
|
|
116
|
+
bundle exec rspec spec/accessibility/all_pages_accessibility_spec.rb
|
|
117
|
+
continue-on-error: true # Don't block PRs initially
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
3. **Gradually enforce:**
|
|
121
|
+
- Start with `continue-on-error: true` to see results
|
|
122
|
+
- Fix existing issues
|
|
123
|
+
- Then set `continue-on-error: false` to enforce
|
|
124
|
+
|
|
125
|
+
### Profile-Based Configuration
|
|
126
|
+
|
|
127
|
+
Use different profiles for different environments:
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
# config/accessibility.yml
|
|
131
|
+
development:
|
|
132
|
+
checks:
|
|
133
|
+
color_contrast: false # Skip expensive checks in dev
|
|
134
|
+
|
|
135
|
+
test:
|
|
136
|
+
checks:
|
|
137
|
+
# Use global settings
|
|
138
|
+
|
|
139
|
+
ci:
|
|
140
|
+
checks:
|
|
141
|
+
color_contrast: true # Full checks in CI
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Then set profile in CI:
|
|
145
|
+
```bash
|
|
146
|
+
RAILS_A11Y_PROFILE=ci bundle exec rspec spec/accessibility/
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Development Workflow Best Practices
|
|
150
|
+
|
|
151
|
+
### 1. Use Static Scanner During Development
|
|
152
|
+
|
|
153
|
+
Add to `Procfile.dev`:
|
|
154
|
+
```procfile
|
|
155
|
+
a11y: bundle exec a11y_static_scanner
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Benefits:**
|
|
159
|
+
- Fast feedback without browser
|
|
160
|
+
- Only scans changed files
|
|
161
|
+
- Continuous monitoring as you code
|
|
162
|
+
- Precise file locations and line numbers
|
|
163
|
+
|
|
164
|
+
### 2. Manual Testing When Needed
|
|
165
|
+
|
|
166
|
+
Run accessibility tests explicitly:
|
|
167
|
+
```bash
|
|
168
|
+
# Test all pages
|
|
169
|
+
rspec spec/accessibility/all_pages_accessibility_spec.rb
|
|
170
|
+
|
|
171
|
+
# Test specific page
|
|
172
|
+
rspec spec/system/home_page_accessibility_spec.rb
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 3. Fix Issues Incrementally
|
|
176
|
+
|
|
177
|
+
1. **Start with critical issues** - Focus on errors first
|
|
178
|
+
2. **Fix by file** - Address all issues in one file at a time
|
|
179
|
+
3. **Test incrementally** - Run tests after each fix
|
|
180
|
+
4. **Document exceptions** - Use `ignored_rules` with reasons
|
|
181
|
+
|
|
182
|
+
## Configuration File Best Practices
|
|
183
|
+
|
|
184
|
+
### Documentation URLs
|
|
185
|
+
|
|
186
|
+
Always use the correct documentation URL:
|
|
187
|
+
```yaml
|
|
188
|
+
# See https://rayraycodes.github.io/rails-accessibility-testing/ for full documentation.
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Comprehensive Comments
|
|
192
|
+
|
|
193
|
+
Add detailed comments explaining decisions:
|
|
194
|
+
```yaml
|
|
195
|
+
# Global enable/disable flag for all accessibility checks
|
|
196
|
+
# Set to false to completely disable all accessibility checks (manual and automatic)
|
|
197
|
+
# When false, check_comprehensive_accessibility and automatic checks will be skipped
|
|
198
|
+
# Default: false
|
|
199
|
+
# (Set to false to allow other RSpec tests to pass in GitHub Actions CI even if accessibility tests fail.
|
|
200
|
+
# When true, any failing accessibility tests will cause the entire CI pipeline to fail.)
|
|
201
|
+
# Set to true to run accessibility checks manually: rspec spec/accessibility/all_pages_accessibility_spec.rb
|
|
202
|
+
accessibility_enabled: false
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Test Spec Best Practices
|
|
206
|
+
|
|
207
|
+
### 1. Use Proper Test Assertions
|
|
208
|
+
|
|
209
|
+
**Recommended:**
|
|
210
|
+
```ruby
|
|
211
|
+
if errors.any? || warnings.any?
|
|
212
|
+
expect(errors).to be_empty, format_static_errors(errors, warnings)
|
|
213
|
+
else
|
|
214
|
+
puts "\n✅ #{view_file}: No errors found"
|
|
215
|
+
end
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Why?**
|
|
219
|
+
- Cleaner test output
|
|
220
|
+
- Proper RSpec integration
|
|
221
|
+
- Better error messages
|
|
222
|
+
- Only fails on errors, not warnings
|
|
223
|
+
|
|
224
|
+
### 2. Improved Error Formatting
|
|
225
|
+
|
|
226
|
+
Use unified formatting method:
|
|
227
|
+
```ruby
|
|
228
|
+
def format_issues_by_file(issues_by_file, output, issue_type)
|
|
229
|
+
issues_by_file.each_with_index do |(file_path, file_issues), file_index|
|
|
230
|
+
output << "" if file_index > 0
|
|
231
|
+
output << "📝 #{file_path} (#{file_issues.length} #{issue_type}#{'s' if file_issues.length != 1})"
|
|
232
|
+
# ... format each issue
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Benefits:**
|
|
238
|
+
- Consistent formatting
|
|
239
|
+
- Better readability
|
|
240
|
+
- Easier to maintain
|
|
241
|
+
|
|
242
|
+
## Summary
|
|
243
|
+
|
|
244
|
+
These best practices are based on real-world production usage and help ensure:
|
|
245
|
+
|
|
246
|
+
1. **CI/CD Safety** - Accessibility tests don't block other tests
|
|
247
|
+
2. **Production Safety** - No errors if gem isn't available
|
|
248
|
+
3. **Developer Control** - Explicit control over when checks run
|
|
249
|
+
4. **Better UX** - Improved error formatting and test output
|
|
250
|
+
5. **Incremental Adoption** - Easy to start and gradually enforce
|
|
251
|
+
|
|
252
|
+
## Credits
|
|
253
|
+
|
|
254
|
+
These best practices were refined based on contributions from:
|
|
255
|
+
- **Margarita Barvinok** - Production configuration improvements
|
|
256
|
+
- Real-world usage in Rails applications
|
|
257
|
+
- Community feedback and testing
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
**Questions?** See the main [README](../README.md) or open an issue.
|
|
@@ -280,6 +280,7 @@ Upload reports to:
|
|
|
280
280
|
3. **Fail on violations** - Don't allow merging with issues
|
|
281
281
|
4. **Report results** - Make status visible to team
|
|
282
282
|
5. **Track trends** - Monitor violation counts over time
|
|
283
|
+
6. **Disable by default** - Set `accessibility_enabled: false` in `config/accessibility.yml` to prevent accessibility tests from blocking other RSpec tests in CI. Enable manually when needed: `rspec spec/accessibility/all_pages_accessibility_spec.rb`
|
|
283
284
|
|
|
284
285
|
## Troubleshooting
|
|
285
286
|
|
data/README.md
CHANGED
|
@@ -447,6 +447,7 @@ Complete documentation site with all guides, examples, and API reference. The do
|
|
|
447
447
|
### Guides
|
|
448
448
|
|
|
449
449
|
- **[System Specs for Accessibility](GUIDES/system_specs_for_accessibility.md)** - ⭐ **Recommended approach** - Using system specs for reliable accessibility testing
|
|
450
|
+
- **[Best Practices](GUIDES/best_practices.md)** - ⭐ **Configuration recommendations** - Production-tested configuration patterns
|
|
450
451
|
- **[Getting Started](GUIDES/getting_started.md)** - Quick start guide
|
|
451
452
|
- **[Continuous Integration](GUIDES/continuous_integration.md)** - CI/CD setup
|
|
452
453
|
- **[Writing Accessible Views](GUIDES/writing_accessible_views_in_rails.md)** - Best practices
|
|
@@ -43,7 +43,11 @@ module RailsA11y
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def create_all_pages_spec
|
|
46
|
-
|
|
46
|
+
# Create spec/accessibility directory if it doesn't exist
|
|
47
|
+
spec_dir = 'spec/accessibility'
|
|
48
|
+
FileUtils.mkdir_p(spec_dir) unless File.directory?(spec_dir)
|
|
49
|
+
|
|
50
|
+
spec_path = 'spec/accessibility/all_pages_accessibility_spec.rb'
|
|
47
51
|
|
|
48
52
|
if File.exist?(spec_path)
|
|
49
53
|
say "⚠️ #{spec_path} already exists. Skipping creation.", :yellow
|
|
@@ -113,7 +117,7 @@ module RailsA11y
|
|
|
113
117
|
say "\n📋 Next Steps:", :yellow
|
|
114
118
|
say ""
|
|
115
119
|
say " 1. Run the accessibility tests:", :cyan
|
|
116
|
-
say " bundle exec rspec spec/
|
|
120
|
+
say " bundle exec rspec spec/accessibility/all_pages_accessibility_spec.rb"
|
|
117
121
|
say ""
|
|
118
122
|
say " 2. For static file scanning during development:", :cyan
|
|
119
123
|
say " bin/dev # Starts web server + static accessibility scanner"
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# Rails A11y Configuration
|
|
2
2
|
#
|
|
3
3
|
# This file configures accessibility checks for your Rails application.
|
|
4
|
-
# See https://github.
|
|
4
|
+
# See https://rayraycodes.github.io/rails-accessibility-testing/ for full documentation.
|
|
5
5
|
|
|
6
6
|
# Global enable/disable flag for all accessibility checks
|
|
7
7
|
# Set to false to completely disable all accessibility checks (manual and automatic)
|
|
8
8
|
# When false, check_comprehensive_accessibility and automatic checks will be skipped
|
|
9
|
-
# Default:
|
|
10
|
-
|
|
9
|
+
# Default: false
|
|
10
|
+
# (Set to false to allow other RSpec tests to pass in GitHub Actions CI even if accessibility tests fail.
|
|
11
|
+
# When true, any failing accessibility tests will cause the entire CI pipeline to fail.)
|
|
12
|
+
# Set to true to run accessibility checks manually: rspec spec/accessibility/all_pages_accessibility_spec.rb
|
|
13
|
+
accessibility_enabled: false
|
|
11
14
|
|
|
12
15
|
# WCAG compliance level (A, AA, AAA)
|
|
13
16
|
wcag_level: AA
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'rails_helper'
|
|
2
2
|
|
|
3
|
-
RSpec.describe 'All Pages Accessibility', type: :
|
|
3
|
+
RSpec.describe 'All Pages Accessibility', type: :accessibility do
|
|
4
4
|
# Test all view files for accessibility using static file scanning
|
|
5
5
|
# Generated automatically by rails_a11y:install generator
|
|
6
6
|
|
|
@@ -35,7 +35,7 @@ RSpec.describe 'All Pages Accessibility', type: :system do
|
|
|
35
35
|
|
|
36
36
|
output = []
|
|
37
37
|
|
|
38
|
-
# Group errors by file
|
|
38
|
+
# Group errors and warnings by file
|
|
39
39
|
errors_by_file = errors.group_by { |e| e[:file] }
|
|
40
40
|
warnings_by_file = warnings.group_by { |w| w[:file] }
|
|
41
41
|
|
|
@@ -43,37 +43,8 @@ RSpec.describe 'All Pages Accessibility', type: :system do
|
|
|
43
43
|
if errors.any?
|
|
44
44
|
output << "\n" + "="*70
|
|
45
45
|
output << "❌ #{errors.length} error#{'s' if errors.length != 1} found"
|
|
46
|
-
output << "="*70
|
|
47
46
|
output << ""
|
|
48
|
-
|
|
49
|
-
errors_by_file.each_with_index do |(file_path, file_errors), file_index|
|
|
50
|
-
output << "" if file_index > 0
|
|
51
|
-
|
|
52
|
-
output << "📝 #{file_path} (#{file_errors.length} error#{'s' if file_errors.length != 1})"
|
|
53
|
-
|
|
54
|
-
file_errors.each do |error|
|
|
55
|
-
error_line = " • #{error[:type]}"
|
|
56
|
-
|
|
57
|
-
# Add line number if available
|
|
58
|
-
if error[:line]
|
|
59
|
-
error_line += " [Line #{error[:line]}]"
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# Add element identifier
|
|
63
|
-
if error[:element][:id].present?
|
|
64
|
-
error_line += " [id: #{error[:element][:id]}]"
|
|
65
|
-
elsif error[:element][:href].present?
|
|
66
|
-
href_display = error[:element][:href].length > 30 ? "#{error[:element][:href][0..27]}..." : error[:element][:href]
|
|
67
|
-
error_line += " [href: #{href_display}]"
|
|
68
|
-
elsif error[:element][:src].present?
|
|
69
|
-
src_display = error[:element][:src].length > 30 ? "#{error[:element][:src][0..27]}..." : error[:element][:src]
|
|
70
|
-
error_line += " [src: #{src_display}]"
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
output << error_line
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
47
|
+
format_issues_by_file(errors_by_file, output, 'error')
|
|
77
48
|
output << ""
|
|
78
49
|
output << "="*70
|
|
79
50
|
end
|
|
@@ -85,33 +56,7 @@ RSpec.describe 'All Pages Accessibility', type: :system do
|
|
|
85
56
|
output << "="*70
|
|
86
57
|
output << ""
|
|
87
58
|
|
|
88
|
-
warnings_by_file
|
|
89
|
-
output << "" if file_index > 0
|
|
90
|
-
|
|
91
|
-
output << "📝 #{file_path} (#{file_warnings.length} warning#{'s' if file_warnings.length != 1})"
|
|
92
|
-
|
|
93
|
-
file_warnings.each do |warning|
|
|
94
|
-
warning_line = " • #{warning[:type]}"
|
|
95
|
-
|
|
96
|
-
# Add line number if available
|
|
97
|
-
if warning[:line]
|
|
98
|
-
warning_line += " [Line #{warning[:line]}]"
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# Add element identifier
|
|
102
|
-
if warning[:element][:id].present?
|
|
103
|
-
warning_line += " [id: #{warning[:element][:id]}]"
|
|
104
|
-
elsif warning[:element][:href].present?
|
|
105
|
-
href_display = warning[:element][:href].length > 30 ? "#{warning[:element][:href][0..27]}..." : warning[:element][:href]
|
|
106
|
-
warning_line += " [href: #{href_display}]"
|
|
107
|
-
elsif warning[:element][:src].present?
|
|
108
|
-
src_display = warning[:element][:src].length > 30 ? "#{warning[:element][:src][0..27]}..." : warning[:element][:src]
|
|
109
|
-
warning_line += " [src: #{src_display}]"
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
output << warning_line
|
|
113
|
-
end
|
|
114
|
-
end
|
|
59
|
+
format_issues_by_file(warnings_by_file, output, 'warning')
|
|
115
60
|
|
|
116
61
|
output << ""
|
|
117
62
|
output << "="*70
|
|
@@ -119,6 +64,36 @@ RSpec.describe 'All Pages Accessibility', type: :system do
|
|
|
119
64
|
|
|
120
65
|
output.join("\n")
|
|
121
66
|
end
|
|
67
|
+
|
|
68
|
+
def format_issues_by_file(issues_by_file, output, issue_type)
|
|
69
|
+
issues_by_file.each_with_index do |(file_path, file_issues), file_index|
|
|
70
|
+
output << "" if file_index > 0
|
|
71
|
+
|
|
72
|
+
output << "📝 #{file_path} (#{file_issues.length} #{issue_type}#{'s' if file_issues.length != 1})"
|
|
73
|
+
|
|
74
|
+
file_issues.each do |issue|
|
|
75
|
+
issue_line = " • #{issue[:type]}"
|
|
76
|
+
|
|
77
|
+
# Add line number if available
|
|
78
|
+
if issue[:line]
|
|
79
|
+
issue_line += " [Line #{issue[:line]}]"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Add element identifier
|
|
83
|
+
if issue[:element][:id].present?
|
|
84
|
+
issue_line += " [id: #{issue[:element][:id]}]"
|
|
85
|
+
elsif issue[:element][:href].present?
|
|
86
|
+
href_display = issue[:element][:href].length > 30 ? "#{issue[:element][:href][0..27]}..." : issue[:element][:href]
|
|
87
|
+
issue_line += " [href: #{href_display}]"
|
|
88
|
+
elsif issue[:element][:src].present?
|
|
89
|
+
src_display = issue[:element][:src].length > 30 ? "#{issue[:element][:src][0..27]}..." : issue[:element][:src]
|
|
90
|
+
issue_line += " [src: #{src_display}]"
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
output << issue_line
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
122
97
|
|
|
123
98
|
# Scan all view files statically
|
|
124
99
|
view_files = get_all_view_files
|
|
@@ -139,13 +114,9 @@ RSpec.describe 'All Pages Accessibility', type: :system do
|
|
|
139
114
|
warnings = result[:warnings] || []
|
|
140
115
|
|
|
141
116
|
if errors.any? || warnings.any?
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if errors.any?
|
|
145
|
-
puts "Found #{errors.length} accessibility error#{'s' if errors.length != 1} in #{view_file}"
|
|
146
|
-
end
|
|
117
|
+
expect(errors).to be_empty, format_static_errors(errors, warnings)
|
|
147
118
|
else
|
|
148
|
-
puts "✅ #{view_file}: No errors found"
|
|
119
|
+
puts "\n✅ #{view_file}: No errors found"
|
|
149
120
|
end
|
|
150
121
|
end
|
|
151
122
|
end
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
#
|
|
5
5
|
# Configure accessibility testing behavior for your Rails application.
|
|
6
6
|
#
|
|
7
|
-
# @see https://github.
|
|
7
|
+
# @see https://rayraycodes.github.io/rails-accessibility-testing/ for documentation
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
# Only configure if the gem is available (not in production)
|
|
10
|
+
if defined?(RailsAccessibilityTesting)
|
|
11
|
+
RailsAccessibilityTesting.configure do |config|
|
|
12
|
+
# Automatically run checks after system specs
|
|
13
|
+
# Set to false to disable automatic checks
|
|
14
|
+
config.auto_run_checks = false
|
|
13
15
|
|
|
14
16
|
# Logger for accessibility check output
|
|
15
17
|
# Set to nil to use default logger
|
|
@@ -18,7 +20,8 @@ RailsAccessibilityTesting.configure do |config|
|
|
|
18
20
|
# Configuration file path (relative to Rails.root)
|
|
19
21
|
# config.config_path = 'config/accessibility.yml'
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
# Default profile to use (development, test, ci)
|
|
24
|
+
# config.default_profile = :test
|
|
25
|
+
end
|
|
23
26
|
end
|
|
24
27
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Regan Maharjan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: axe-core-capybara
|
|
@@ -97,6 +97,7 @@ files:
|
|
|
97
97
|
- CHANGELOG.md
|
|
98
98
|
- CODE_OF_CONDUCT.md
|
|
99
99
|
- CONTRIBUTING.md
|
|
100
|
+
- GUIDES/best_practices.md
|
|
100
101
|
- GUIDES/continuous_integration.md
|
|
101
102
|
- GUIDES/getting_started.md
|
|
102
103
|
- GUIDES/system_specs_for_accessibility.md
|