rails_accessibility_testing 1.1.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.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/ARCHITECTURE.md +307 -0
  3. data/CHANGELOG.md +81 -0
  4. data/CODE_OF_CONDUCT.md +125 -0
  5. data/CONTRIBUTING.md +225 -0
  6. data/GUIDES/continuous_integration.md +326 -0
  7. data/GUIDES/getting_started.md +205 -0
  8. data/GUIDES/working_with_designers_and_content_authors.md +398 -0
  9. data/GUIDES/writing_accessible_views_in_rails.md +412 -0
  10. data/LICENSE +22 -0
  11. data/README.md +350 -0
  12. data/docs_site/404.html +11 -0
  13. data/docs_site/Gemfile +11 -0
  14. data/docs_site/Makefile +14 -0
  15. data/docs_site/_config.yml +41 -0
  16. data/docs_site/_includes/header.html +13 -0
  17. data/docs_site/_layouts/default.html +130 -0
  18. data/docs_site/assets/main.scss +4 -0
  19. data/docs_site/ci_integration.md +76 -0
  20. data/docs_site/configuration.md +114 -0
  21. data/docs_site/contributing.md +69 -0
  22. data/docs_site/getting_started.md +57 -0
  23. data/docs_site/index.md +57 -0
  24. data/exe/rails_a11y +12 -0
  25. data/exe/rails_server_safe +41 -0
  26. data/lib/generators/rails_a11y/install/generator.rb +51 -0
  27. data/lib/rails_accessibility_testing/accessibility_helper.rb +701 -0
  28. data/lib/rails_accessibility_testing/change_detector.rb +114 -0
  29. data/lib/rails_accessibility_testing/checks/aria_landmarks_check.rb +33 -0
  30. data/lib/rails_accessibility_testing/checks/base_check.rb +156 -0
  31. data/lib/rails_accessibility_testing/checks/color_contrast_check.rb +56 -0
  32. data/lib/rails_accessibility_testing/checks/duplicate_ids_check.rb +49 -0
  33. data/lib/rails_accessibility_testing/checks/form_errors_check.rb +40 -0
  34. data/lib/rails_accessibility_testing/checks/form_labels_check.rb +62 -0
  35. data/lib/rails_accessibility_testing/checks/heading_hierarchy_check.rb +53 -0
  36. data/lib/rails_accessibility_testing/checks/image_alt_text_check.rb +52 -0
  37. data/lib/rails_accessibility_testing/checks/interactive_elements_check.rb +66 -0
  38. data/lib/rails_accessibility_testing/checks/keyboard_accessibility_check.rb +36 -0
  39. data/lib/rails_accessibility_testing/checks/skip_links_check.rb +24 -0
  40. data/lib/rails_accessibility_testing/checks/table_structure_check.rb +36 -0
  41. data/lib/rails_accessibility_testing/cli/command.rb +259 -0
  42. data/lib/rails_accessibility_testing/config/yaml_loader.rb +131 -0
  43. data/lib/rails_accessibility_testing/configuration.rb +30 -0
  44. data/lib/rails_accessibility_testing/engine/rule_engine.rb +97 -0
  45. data/lib/rails_accessibility_testing/engine/violation.rb +58 -0
  46. data/lib/rails_accessibility_testing/engine/violation_collector.rb +59 -0
  47. data/lib/rails_accessibility_testing/error_message_builder.rb +354 -0
  48. data/lib/rails_accessibility_testing/integration/minitest_integration.rb +74 -0
  49. data/lib/rails_accessibility_testing/rspec_integration.rb +58 -0
  50. data/lib/rails_accessibility_testing/shared_examples.rb +93 -0
  51. data/lib/rails_accessibility_testing/version.rb +4 -0
  52. data/lib/rails_accessibility_testing.rb +83 -0
  53. data/lib/tasks/accessibility.rake +28 -0
  54. metadata +218 -0
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,225 @@
1
+ # Contributing to Rails Accessibility Testing
2
+
3
+ Thank you for your interest in contributing to Rails Accessibility Testing! This document provides guidelines and instructions for contributing.
4
+
5
+ ## 🤝 Code of Conduct
6
+
7
+ This project adheres to a code of conduct that all contributors are expected to follow. Please be respectful and constructive in all interactions.
8
+
9
+ ## 🚀 Getting Started
10
+
11
+ ### Prerequisites
12
+
13
+ - Ruby 3.0+ installed
14
+ - Bundler installed
15
+ - Git installed
16
+ - A GitHub account
17
+
18
+ ### Setting Up Development Environment
19
+
20
+ 1. **Fork the repository**
21
+ ```bash
22
+ # Fork on GitHub, then clone your fork
23
+ git clone https://github.com/your-username/rails-accessibility-testing.git
24
+ cd rails-accessibility-testing
25
+ ```
26
+
27
+ 2. **Install dependencies**
28
+ ```bash
29
+ bundle install
30
+ ```
31
+
32
+ 3. **Run tests**
33
+ ```bash
34
+ bundle exec rspec
35
+ ```
36
+
37
+ ## 📝 Making Changes
38
+
39
+ ### Development Workflow
40
+
41
+ 1. **Create a branch**
42
+ ```bash
43
+ git checkout -b feature/your-feature-name
44
+ # or
45
+ git checkout -b fix/your-bug-fix
46
+ ```
47
+
48
+ 2. **Make your changes**
49
+ - Write code
50
+ - Add tests
51
+ - Update documentation
52
+
53
+ 3. **Test your changes**
54
+ ```bash
55
+ bundle exec rspec
56
+ ```
57
+
58
+ 4. **Commit your changes**
59
+ ```bash
60
+ git add .
61
+ git commit -m "Add: descriptive commit message"
62
+ ```
63
+
64
+ 5. **Push to your fork**
65
+ ```bash
66
+ git push origin feature/your-feature-name
67
+ ```
68
+
69
+ 6. **Open a Pull Request**
70
+ - Go to the original repository on GitHub
71
+ - Click "New Pull Request"
72
+ - Select your branch
73
+ - Fill out the PR template
74
+
75
+ ## 📋 Commit Message Guidelines
76
+
77
+ We follow conventional commit message format:
78
+
79
+ ```
80
+ type: short description
81
+
82
+ Longer description if needed
83
+
84
+ - Bullet point 1
85
+ - Bullet point 2
86
+ ```
87
+
88
+ **Types:**
89
+ - `Add:` - New feature
90
+ - `Fix:` - Bug fix
91
+ - `Update:` - Update existing feature
92
+ - `Refactor:` - Code refactoring
93
+ - `Docs:` - Documentation changes
94
+ - `Test:` - Test additions/changes
95
+ - `Chore:` - Maintenance tasks
96
+
97
+ **Examples:**
98
+ ```
99
+ Add: support for custom accessibility rules
100
+
101
+ Allows users to define custom accessibility checks
102
+ beyond the default 11 checks.
103
+
104
+ - Add configuration for custom rules
105
+ - Add validation for custom rule format
106
+ - Update documentation
107
+ ```
108
+
109
+ ## 🧪 Testing
110
+
111
+ ### Running Tests
112
+
113
+ ```bash
114
+ # Run all tests
115
+ bundle exec rspec
116
+
117
+ # Run specific test file
118
+ bundle exec rspec spec/path/to/spec.rb
119
+
120
+ # Run with coverage
121
+ COVERAGE=true bundle exec rspec
122
+ ```
123
+
124
+ ### Writing Tests
125
+
126
+ - Write tests for all new features
127
+ - Ensure existing tests still pass
128
+ - Aim for good test coverage
129
+ - Test edge cases
130
+
131
+ ## 📚 Documentation
132
+
133
+ ### Updating Documentation
134
+
135
+ - Update README.md for user-facing changes
136
+ - Update CHANGELOG.md for all changes
137
+ - Update inline code documentation
138
+ - Update setup guides if needed
139
+
140
+ ### Documentation Standards
141
+
142
+ - Use clear, concise language
143
+ - Include code examples
144
+ - Explain the "why" not just the "what"
145
+ - Keep examples up-to-date
146
+
147
+ ## 🐛 Reporting Bugs
148
+
149
+ ### Before Submitting
150
+
151
+ 1. Check if the bug has already been reported
152
+ 2. Check if it's fixed in the latest version
153
+ 3. Try to reproduce the issue
154
+
155
+ ### Bug Report Template
156
+
157
+ ```markdown
158
+ **Describe the bug**
159
+ A clear description of what the bug is.
160
+
161
+ **To Reproduce**
162
+ Steps to reproduce:
163
+ 1. ...
164
+ 2. ...
165
+
166
+ **Expected behavior**
167
+ What you expected to happen.
168
+
169
+ **Actual behavior**
170
+ What actually happened.
171
+
172
+ **Environment**
173
+ - Ruby version:
174
+ - Rails version:
175
+ - RSpec version:
176
+ - Gem version:
177
+
178
+ **Additional context**
179
+ Any other relevant information.
180
+ ```
181
+
182
+ ## 💡 Suggesting Features
183
+
184
+ ### Feature Request Template
185
+
186
+ ```markdown
187
+ **Is your feature request related to a problem?**
188
+ A clear description of the problem.
189
+
190
+ **Describe the solution you'd like**
191
+ What you want to happen.
192
+
193
+ **Describe alternatives you've considered**
194
+ Other solutions you've thought about.
195
+
196
+ **Additional context**
197
+ Any other relevant information.
198
+ ```
199
+
200
+ ## 🔍 Code Review Process
201
+
202
+ 1. All PRs require at least one approval
203
+ 2. Maintainers will review your code
204
+ 3. Address any feedback
205
+ 4. Once approved, maintainers will merge
206
+
207
+ ## 📦 Releasing
208
+
209
+ Only maintainers can release new versions. The process:
210
+
211
+ 1. Update version in `lib/rails_accessibility_testing/version.rb`
212
+ 2. Update CHANGELOG.md
213
+ 3. Create git tag
214
+ 4. Build and push gem to RubyGems
215
+
216
+ ## ❓ Questions?
217
+
218
+ - Open an issue for questions
219
+ - Check existing issues and discussions
220
+ - Email: imregan@umich.edu
221
+
222
+ ## 🙏 Thank You!
223
+
224
+ Your contributions make this project better for everyone. Thank you for taking the time to contribute!
225
+
@@ -0,0 +1,326 @@
1
+ # Continuous Integration with Rails A11y
2
+
3
+ This guide shows you how to integrate Rails A11y into your CI/CD pipeline to catch accessibility issues before they reach production.
4
+
5
+ ## Why CI Integration?
6
+
7
+ - **Catch issues early** - Before code is merged
8
+ - **Prevent regressions** - Ensure fixes stay fixed
9
+ - **Team accountability** - Everyone sees accessibility status
10
+ - **Compliance tracking** - Document WCAG compliance
11
+
12
+ ## GitHub Actions
13
+
14
+ ### Basic Setup
15
+
16
+ Create `.github/workflows/accessibility.yml`:
17
+
18
+ ```yaml
19
+ name: Accessibility Tests
20
+
21
+ on:
22
+ pull_request:
23
+ push:
24
+ branches: [main]
25
+
26
+ jobs:
27
+ accessibility:
28
+ runs-on: ubuntu-latest
29
+
30
+ services:
31
+ postgres:
32
+ image: postgres:14
33
+ env:
34
+ POSTGRES_PASSWORD: postgres
35
+ options: >-
36
+ --health-cmd pg_isready
37
+ --health-interval 10s
38
+ --health-timeout 5s
39
+ --health-retries 5
40
+
41
+ steps:
42
+ - uses: actions/checkout@v3
43
+
44
+ - name: Set up Ruby
45
+ uses: ruby/setup-ruby@v1
46
+ with:
47
+ ruby-version: 3.1
48
+ bundler-cache: true
49
+
50
+ - name: Install Chrome
51
+ run: |
52
+ sudo apt-get update
53
+ sudo apt-get install -y google-chrome-stable
54
+
55
+ - name: Setup test database
56
+ env:
57
+ RAILS_ENV: test
58
+ DATABASE_URL: postgres://postgres:postgres@localhost/test
59
+ run: |
60
+ bundle exec rails db:create db:schema:load
61
+
62
+ - name: Run accessibility tests
63
+ env:
64
+ RAILS_ENV: test
65
+ DATABASE_URL: postgres://postgres:postgres@localhost/test
66
+ run: |
67
+ bundle exec rspec spec/system/ --format documentation
68
+
69
+ - name: Upload accessibility report
70
+ if: failure()
71
+ uses: actions/upload-artifact@v3
72
+ with:
73
+ name: accessibility-report
74
+ path: accessibility-report.json
75
+ ```
76
+
77
+ ### Advanced: JSON Report
78
+
79
+ Generate a JSON report for programmatic access:
80
+
81
+ ```yaml
82
+ - name: Run accessibility tests with JSON report
83
+ run: |
84
+ bundle exec rails_a11y check --format json --output accessibility-report.json
85
+ ```
86
+
87
+ ### Comment on PR
88
+
89
+ Add a comment to PRs with accessibility status:
90
+
91
+ ```yaml
92
+ - name: Comment on PR
93
+ if: github.event_name == 'pull_request'
94
+ uses: actions/github-script@v6
95
+ with:
96
+ script: |
97
+ const fs = require('fs');
98
+ const report = JSON.parse(fs.readFileSync('accessibility-report.json', 'utf8'));
99
+
100
+ const comment = `## Accessibility Report
101
+
102
+ **Status:** ${report.summary.total_violations === 0 ? '✅ Pass' : '❌ Fail'}
103
+ **Violations:** ${report.summary.total_violations}
104
+ **URLs Checked:** ${report.summary.urls_checked}
105
+
106
+ ${report.summary.total_violations > 0 ? 'Please fix accessibility issues before merging.' : 'All accessibility checks passed!'}
107
+ `;
108
+
109
+ github.rest.issues.createComment({
110
+ issue_number: context.issue.number,
111
+ owner: context.repo.owner,
112
+ repo: context.repo.repo,
113
+ body: comment
114
+ });
115
+ ```
116
+
117
+ ## CircleCI
118
+
119
+ ### Basic Configuration
120
+
121
+ Add to `.circleci/config.yml`:
122
+
123
+ ```yaml
124
+ version: 2.1
125
+
126
+ jobs:
127
+ accessibility:
128
+ docker:
129
+ - image: cimg/ruby:3.1
130
+ environment:
131
+ RAILS_ENV: test
132
+ steps:
133
+ - checkout
134
+ - restore_cache:
135
+ keys:
136
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
137
+ - run:
138
+ name: Install dependencies
139
+ command: bundle install
140
+ - run:
141
+ name: Setup database
142
+ command: bundle exec rails db:create db:schema:load
143
+ - run:
144
+ name: Run accessibility tests
145
+ command: bundle exec rspec spec/system/
146
+ ```
147
+
148
+ ## GitLab CI
149
+
150
+ ### Basic Configuration
151
+
152
+ Add to `.gitlab-ci.yml`:
153
+
154
+ ```yaml
155
+ accessibility:
156
+ image: ruby:3.1
157
+ services:
158
+ - postgres:14
159
+ variables:
160
+ RAILS_ENV: test
161
+ POSTGRES_DB: test
162
+ POSTGRES_USER: postgres
163
+ POSTGRES_PASSWORD: postgres
164
+ before_script:
165
+ - apt-get update -qq && apt-get install -y -qq postgresql-client
166
+ - bundle install
167
+ - bundle exec rails db:create db:schema:load
168
+ script:
169
+ - bundle exec rspec spec/system/
170
+ artifacts:
171
+ when: on_failure
172
+ paths:
173
+ - accessibility-report.json
174
+ reports:
175
+ junit: accessibility-report.xml
176
+ ```
177
+
178
+ ## Jenkins
179
+
180
+ ### Pipeline Script
181
+
182
+ ```groovy
183
+ pipeline {
184
+ agent any
185
+
186
+ stages {
187
+ stage('Accessibility Tests') {
188
+ steps {
189
+ sh 'bundle install'
190
+ sh 'bundle exec rails db:create db:schema:load RAILS_ENV=test'
191
+ sh 'bundle exec rspec spec/system/'
192
+ }
193
+ }
194
+ }
195
+
196
+ post {
197
+ always {
198
+ archiveArtifacts artifacts: 'accessibility-report.json', allowEmptyArchive: true
199
+ }
200
+ }
201
+ }
202
+ ```
203
+
204
+ ## CI Configuration Tips
205
+
206
+ ### Use CI Profile
207
+
208
+ Configure stricter checks in CI:
209
+
210
+ ```yaml
211
+ # config/accessibility.yml
212
+ ci:
213
+ checks:
214
+ color_contrast: true # Enable expensive checks in CI
215
+ skip_links: true # Require skip links in production
216
+ ```
217
+
218
+ Then set the profile in CI:
219
+
220
+ ```bash
221
+ RAILS_A11Y_PROFILE=ci bundle exec rspec spec/system/
222
+ ```
223
+
224
+ ### Fail Fast
225
+
226
+ Make accessibility failures block merges:
227
+
228
+ ```yaml
229
+ # GitHub Actions
230
+ - name: Run accessibility tests
231
+ run: bundle exec rspec spec/system/
232
+ continue-on-error: false # Fail the build on errors
233
+ ```
234
+
235
+ ### Parallel Execution
236
+
237
+ Run accessibility tests in parallel with other tests:
238
+
239
+ ```yaml
240
+ strategy:
241
+ matrix:
242
+ test_type: [unit, integration, accessibility]
243
+ ```
244
+
245
+ ### Cache Dependencies
246
+
247
+ Speed up CI runs by caching:
248
+
249
+ ```yaml
250
+ - name: Cache gems
251
+ uses: actions/cache@v3
252
+ with:
253
+ path: vendor/bundle
254
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
255
+ ```
256
+
257
+ ## Reporting
258
+
259
+ ### Generate Reports
260
+
261
+ ```bash
262
+ # Human-readable report
263
+ bundle exec rails_a11y check --format human --output report.txt
264
+
265
+ # JSON report for programmatic access
266
+ bundle exec rails_a11y check --format json --output report.json
267
+ ```
268
+
269
+ ### Share Reports
270
+
271
+ Upload reports to:
272
+ - **GitHub Actions Artifacts** - Automatic artifact upload
273
+ - **S3/Cloud Storage** - For long-term storage
274
+ - **Slack/Email** - Notify team of failures
275
+
276
+ ## Best Practices
277
+
278
+ 1. **Run on every PR** - Catch issues before merge
279
+ 2. **Use CI profile** - Stricter checks in CI than dev
280
+ 3. **Fail on violations** - Don't allow merging with issues
281
+ 4. **Report results** - Make status visible to team
282
+ 5. **Track trends** - Monitor violation counts over time
283
+
284
+ ## Troubleshooting
285
+
286
+ ### Tests Time Out
287
+
288
+ If tests are slow, disable expensive checks:
289
+
290
+ ```yaml
291
+ ci:
292
+ checks:
293
+ color_contrast: false # Disable if too slow
294
+ ```
295
+
296
+ ### Chrome Not Found
297
+
298
+ Install Chrome in CI:
299
+
300
+ ```yaml
301
+ - name: Install Chrome
302
+ run: |
303
+ wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
304
+ sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
305
+ sudo apt-get update
306
+ sudo apt-get install -y google-chrome-stable
307
+ ```
308
+
309
+ ### Database Issues
310
+
311
+ Ensure database is set up:
312
+
313
+ ```bash
314
+ bundle exec rails db:create db:schema:load RAILS_ENV=test
315
+ ```
316
+
317
+ ## Next Steps
318
+
319
+ - **Set up notifications** - Get alerts when checks fail
320
+ - **Track metrics** - Monitor accessibility over time
321
+ - **Automate fixes** - Use reports to prioritize work
322
+
323
+ ---
324
+
325
+ **Questions?** See the main [README](../README.md) or open an issue.
326
+