rails_accessibility_testing 1.4.3 → 1.5.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/ARCHITECTURE.md +212 -53
- data/CHANGELOG.md +118 -0
- data/GUIDES/getting_started.md +105 -77
- data/GUIDES/system_specs_for_accessibility.md +13 -12
- data/README.md +150 -36
- data/docs_site/getting_started.md +59 -69
- data/exe/a11y_live_scanner +361 -0
- data/exe/rails_server_safe +18 -1
- data/lib/generators/rails_a11y/install/install_generator.rb +137 -0
- data/lib/generators/rails_a11y/install/templates/accessibility.yml.erb +49 -0
- data/lib/generators/rails_a11y/install/templates/all_pages_accessibility_spec.rb.erb +66 -0
- data/lib/generators/rails_a11y/install/templates/initializer.rb.erb +24 -0
- data/lib/rails_accessibility_testing/accessibility_helper.rb +547 -24
- data/lib/rails_accessibility_testing/change_detector.rb +17 -104
- data/lib/rails_accessibility_testing/checks/base_check.rb +56 -7
- data/lib/rails_accessibility_testing/checks/heading_check.rb +138 -0
- data/lib/rails_accessibility_testing/checks/image_alt_text_check.rb +7 -7
- data/lib/rails_accessibility_testing/checks/interactive_elements_check.rb +11 -1
- data/lib/rails_accessibility_testing/cli/command.rb +3 -1
- data/lib/rails_accessibility_testing/config/yaml_loader.rb +1 -1
- data/lib/rails_accessibility_testing/engine/rule_engine.rb +49 -5
- data/lib/rails_accessibility_testing/error_message_builder.rb +63 -7
- data/lib/rails_accessibility_testing/middleware/page_visit_logger.rb +81 -0
- data/lib/rails_accessibility_testing/railtie.rb +22 -0
- data/lib/rails_accessibility_testing/rspec_integration.rb +176 -10
- data/lib/rails_accessibility_testing/version.rb +1 -1
- data/lib/rails_accessibility_testing.rb +8 -3
- metadata +11 -4
- data/lib/generators/rails_a11y/install/generator.rb +0 -51
- data/lib/rails_accessibility_testing/checks/heading_hierarchy_check.rb +0 -53
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Rails A11y Configuration
|
|
2
|
+
#
|
|
3
|
+
# This file configures accessibility checks for your Rails application.
|
|
4
|
+
# See https://github.com/your-org/rails-a11y for full documentation.
|
|
5
|
+
|
|
6
|
+
# WCAG compliance level (A, AA, AAA)
|
|
7
|
+
wcag_level: AA
|
|
8
|
+
|
|
9
|
+
# Global check configuration
|
|
10
|
+
# Set to false to disable a check globally
|
|
11
|
+
checks:
|
|
12
|
+
form_labels: true
|
|
13
|
+
image_alt_text: true
|
|
14
|
+
interactive_elements: true
|
|
15
|
+
heading_hierarchy: true
|
|
16
|
+
keyboard_accessibility: true
|
|
17
|
+
aria_landmarks: true
|
|
18
|
+
form_errors: true
|
|
19
|
+
table_structure: true
|
|
20
|
+
duplicate_ids: true
|
|
21
|
+
skip_links: true
|
|
22
|
+
color_contrast: false # Disabled by default (requires JS evaluation)
|
|
23
|
+
|
|
24
|
+
# Profile-specific configurations
|
|
25
|
+
# Override global settings for different environments
|
|
26
|
+
|
|
27
|
+
development:
|
|
28
|
+
checks:
|
|
29
|
+
color_contrast: false # Skip in dev for speed
|
|
30
|
+
# Add other dev-specific overrides here
|
|
31
|
+
|
|
32
|
+
test:
|
|
33
|
+
checks:
|
|
34
|
+
# Test environment uses global settings by default
|
|
35
|
+
# Add test-specific overrides here
|
|
36
|
+
|
|
37
|
+
ci:
|
|
38
|
+
checks:
|
|
39
|
+
color_contrast: true # Full checks in CI
|
|
40
|
+
# Add CI-specific overrides here
|
|
41
|
+
|
|
42
|
+
# Ignored rules with reasons
|
|
43
|
+
# Use this to temporarily ignore specific rules while fixing issues
|
|
44
|
+
# Always include a reason and plan to fix
|
|
45
|
+
ignored_rules:
|
|
46
|
+
# - rule: form_labels
|
|
47
|
+
# reason: "Legacy form, scheduled for refactor in Q2"
|
|
48
|
+
# comment: "Will be fixed in PR #123"
|
|
49
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe 'All Pages Accessibility', type: :system do
|
|
4
|
+
# Test all GET routes for accessibility
|
|
5
|
+
# Generated automatically by rails_a11y:install generator
|
|
6
|
+
|
|
7
|
+
# Helper method to get all testable routes
|
|
8
|
+
def self.get_testable_routes
|
|
9
|
+
return [] unless defined?(Rails) && Rails.application
|
|
10
|
+
|
|
11
|
+
Rails.application.routes.routes.select do |route|
|
|
12
|
+
next false unless route.verb.to_s.include?('GET')
|
|
13
|
+
|
|
14
|
+
path_spec = route.path.spec.to_s
|
|
15
|
+
|
|
16
|
+
# Exclude API routes, internal Rails routes, and format-specific routes
|
|
17
|
+
next false if path_spec =~ /\.(json|xml|js)/
|
|
18
|
+
next false if path_spec =~ /rails/
|
|
19
|
+
next false if path_spec =~ /active_storage/
|
|
20
|
+
next false if path_spec =~ /action_cable/
|
|
21
|
+
next false if path_spec =~ /letter_opener/
|
|
22
|
+
next false if path_spec =~ /up/
|
|
23
|
+
next false if path_spec =~ /recede_historical_location/
|
|
24
|
+
next false if path_spec =~ /resume_historical_location/
|
|
25
|
+
next false if path_spec =~ /refresh_historical_location/
|
|
26
|
+
|
|
27
|
+
# Skip routes with complex requirements
|
|
28
|
+
next false if path_spec.include?('destroy') || path_spec.include?('delete')
|
|
29
|
+
|
|
30
|
+
# Skip routes with multiple required params (too complex to test automatically)
|
|
31
|
+
param_count = path_spec.scan(/\(:(\w+)\)/).length
|
|
32
|
+
next false if param_count > 1
|
|
33
|
+
|
|
34
|
+
true
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Test each route
|
|
39
|
+
get_testable_routes.each do |route|
|
|
40
|
+
path = RailsAccessibilityTesting::ChangeDetector.route_to_path(route)
|
|
41
|
+
next unless path
|
|
42
|
+
|
|
43
|
+
it "checks accessibility for #{path}" do
|
|
44
|
+
begin
|
|
45
|
+
visit path
|
|
46
|
+
|
|
47
|
+
# Wait for page to load
|
|
48
|
+
sleep 0.5
|
|
49
|
+
|
|
50
|
+
# Skip if redirected to sign in (requires authentication)
|
|
51
|
+
if page.current_url.include?('sign_in') || page.current_url.include?('login')
|
|
52
|
+
skip "Skipping #{path}: requires authentication"
|
|
53
|
+
elsif page.has_content?('Error') || page.has_content?('404') || page.has_content?('Not Found')
|
|
54
|
+
skip "Skipping #{path}: page not found or error"
|
|
55
|
+
else
|
|
56
|
+
# Page loaded successfully, run accessibility checks
|
|
57
|
+
check_comprehensive_accessibility
|
|
58
|
+
end
|
|
59
|
+
rescue => e
|
|
60
|
+
# Skip routes that can't be accessed
|
|
61
|
+
skip "Skipping #{path}: #{e.message}"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Rails A11y Configuration
|
|
4
|
+
#
|
|
5
|
+
# Configure accessibility testing behavior for your Rails application.
|
|
6
|
+
#
|
|
7
|
+
# @see https://github.com/your-org/rails-a11y for documentation
|
|
8
|
+
|
|
9
|
+
RailsAccessibilityTesting.configure do |config|
|
|
10
|
+
# Automatically run checks after system specs
|
|
11
|
+
# Set to false to disable automatic checks
|
|
12
|
+
config.auto_run_checks = true
|
|
13
|
+
|
|
14
|
+
# Logger for accessibility check output
|
|
15
|
+
# Set to nil to use default logger
|
|
16
|
+
# config.logger = Rails.logger
|
|
17
|
+
|
|
18
|
+
# Configuration file path (relative to Rails.root)
|
|
19
|
+
# config.config_path = 'config/accessibility.yml'
|
|
20
|
+
|
|
21
|
+
# Default profile to use (development, test, ci)
|
|
22
|
+
# config.default_profile = :test
|
|
23
|
+
end
|
|
24
|
+
|