Skip to content

Commit bbfcf8f

Browse files
committed
Release v1.5.10: Composed page scanning and accessibility_enabled flag
1 parent 5efc4c0 commit bbfcf8f

18 files changed

Lines changed: 874 additions & 76 deletions

CHANGELOG.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,63 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.5.10] - 2024-12-01
9+
10+
### Changed
11+
- **Configuration flag renamed**: The `enabled` flag has been renamed to `accessibility_enabled` for better clarity. The old `enabled` key is still supported for backward compatibility.
12+
13+
### Added
14+
- **Composed Page Scanning**: The static scanner now analyzes complete page compositions (layout + view + partials) for page-level accessibility checks, eliminating false positives for heading hierarchy, ARIA landmarks, duplicate IDs, and heading issues.
15+
- **View Composition Builder**: New comprehensive system that traces the complete page structure by finding all partials recursively across all directories in `app/views`.
16+
- **Exhaustive Partial Detection**: Enhanced partial detection that finds partials in any subdirectory, not just specific folders. Works for deeply nested namespaces (e.g., `collections/collection_questions`).
17+
- **ERB Content Detection**: Improved handling of ERB expressions (`<%= ... %>`) to prevent false positives for empty headings and missing accessible names on buttons.
18+
19+
### Changed
20+
- **Heading Hierarchy Checks**: Now performed on the complete composed page instead of individual files, preventing false positives when H1 is in layout or partials.
21+
- **ARIA Landmarks Checks**: Now checks for `<main>` landmark across the entire composed page.
22+
- **Duplicate ID Checks**: Now checks for duplicate IDs across the complete page composition.
23+
- **Empty Heading Checks**: Now checks for empty headings across the complete composed page.
24+
- **Partial Search**: Enhanced to traverse ALL folders in `app/views` recursively using `Dir.glob`, making it a general solution that works for any folder structure.
25+
26+
### Fixed
27+
- Fixed false positive for "Page missing MAIN landmark" when `<main>` is in the layout file.
28+
- Fixed false positive for "Page has h2 but no h1 heading" when H1 is in a partial rendered via `render @model`.
29+
- Fixed false positive for "Heading hierarchy skipped (h0 to h2)" when first heading is h2.
30+
- Fixed false positive for "Duplicate ID 'ERB_CONTENT'" by filtering out ERB placeholder strings.
31+
- Fixed partial detection for Rails shorthand patterns (`render @model`, `render collection: @models`).
32+
- Fixed namespaced partial path resolution (e.g., `layouts/_advance_search`).
33+
- Fixed path normalization to handle both relative and absolute paths consistently.
34+
35+
### Performance
36+
- Optimized exhaustive directory search to return first match found instead of checking all matches.
37+
38+
## [Unreleased]
39+
40+
### Added
41+
- **Composed Page Scanning**: The static scanner now analyzes complete page compositions (layout + view + partials) for page-level accessibility checks, eliminating false positives for heading hierarchy, ARIA landmarks, duplicate IDs, and heading issues.
42+
- **View Composition Builder**: New comprehensive system that traces the complete page structure by finding all partials recursively across all directories in `app/views`.
43+
- **Exhaustive Partial Detection**: Enhanced partial detection that finds partials in any subdirectory, not just specific folders. Works for deeply nested namespaces (e.g., `collections/collection_questions`).
44+
- **ERB Content Detection**: Improved handling of ERB expressions (`<%= ... %>`) to prevent false positives for empty headings and missing accessible names on buttons.
45+
46+
### Changed
47+
- **Heading Hierarchy Checks**: Now performed on the complete composed page instead of individual files, preventing false positives when H1 is in layout or partials.
48+
- **ARIA Landmarks Checks**: Now checks for `<main>` landmark across the entire composed page.
49+
- **Duplicate ID Checks**: Now checks for duplicate IDs across the complete page composition.
50+
- **Empty Heading Checks**: Now checks for empty headings across the complete composed page.
51+
- **Partial Search**: Enhanced to traverse ALL folders in `app/views` recursively using `Dir.glob`, making it a general solution that works for any folder structure.
52+
53+
### Fixed
54+
- Fixed false positive for "Page missing MAIN landmark" when `<main>` is in the layout file.
55+
- Fixed false positive for "Page has h2 but no h1 heading" when H1 is in a partial rendered via `render @model`.
56+
- Fixed false positive for "Heading hierarchy skipped (h0 to h2)" when first heading is h2.
57+
- Fixed false positive for "Duplicate ID 'ERB_CONTENT'" by filtering out ERB placeholder strings.
58+
- Fixed partial detection for Rails shorthand patterns (`render @model`, `render collection: @models`).
59+
- Fixed namespaced partial path resolution (e.g., `layouts/_advance_search`).
60+
- Fixed path normalization to handle both relative and absolute paths consistently.
61+
62+
### Performance
63+
- Optimized exhaustive directory search to return first match found instead of checking all matches.
64+
865
## [1.5.9] - 2024-12-01
966

1067
### Added

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
**The RSpec + RuboCop of accessibility for Rails. Catch WCAG violations before they reach production.**
99

10-
**Current Version:** 1.5.5
10+
**Current Version:** 1.5.9
1111

1212
📖 **[📚 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)
1313

@@ -51,6 +51,13 @@ Rails Accessibility Testing fills a critical gap in the Rails testing ecosystem.
5151
- **Accurate error counting**: Properly tracks and displays error/warning counts
5252
- **Persistent output**: Errors stay visible in terminal (no clearing)
5353

54+
#### 🔍 Composed Page Scanning (NEW in 1.5.9+)
55+
- **Complete page analysis**: Analyzes full page composition (layout + view + partials) for page-level checks
56+
- **Eliminates false positives**: No more false positives when H1 is in layout or partials
57+
- **Exhaustive partial finding**: Traverses ALL folders recursively to find all partials
58+
- **Works for any structure**: General solution that works for any Rails folder structure (collections, items, profiles, loan_requests, etc.)
59+
- **Page-level checks**: Heading hierarchy, ARIA landmarks, duplicate IDs, and empty headings checked across complete page
60+
5461
#### 🔍 Smart View File Detection
5562
- **Intelligent matching**: Automatically finds view files even when action names don't match
5663
- **Controller directory scanning**: Searches all view files to find the correct template
@@ -61,6 +68,7 @@ Rails Accessibility Testing fills a critical gap in the Rails testing ecosystem.
6168
- **Optimized DOM queries**: Faster image alt checks without JavaScript evaluation
6269
- **Removed delays**: Eliminated unnecessary sleep calls in live scanner
6370
- **Efficient scanning**: ~25-30% faster page scans
71+
- **Optimized directory search**: Returns first match found instead of checking all matches
6472

6573
#### 🎨 Enhanced Developer Experience
6674
- **Real-time progress**: Step-by-step feedback during accessibility checks

RELEASE_1.5.7.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

docs_site/architecture.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,45 @@ layout: default
33
title: Architecture
44
---
55

6-
# Architecture Overview
6+
# Architecture
7+
8+
## Composed Page Scanning
9+
10+
The gem now uses **composed page scanning** for page-level accessibility checks. This ensures that checks like heading hierarchy, ARIA landmarks, and duplicate IDs are evaluated against the complete rendered page (layout + view + partials), not individual files.
11+
12+
### View Composition Builder
13+
14+
The `ViewCompositionBuilder` class traces the complete page structure:
15+
16+
1. **Finds Layout File**: Identifies the layout file (defaults to `application.html.erb`)
17+
2. **Finds View File**: The main view file being rendered
18+
3. **Recursively Finds Partials**: Discovers all partials rendered in the view, including:
19+
- Partials in the same directory
20+
- Partials in `layouts/`, `shared/`, `application/`
21+
- Partials in any subdirectory (exhaustive search)
22+
- Nested partials (partials within partials)
23+
24+
### Partial Detection
25+
26+
The gem detects all Rails render patterns:
27+
- `render 'partial'`
28+
- `render partial: 'partial'`
29+
- `render @model` (Rails shorthand)
30+
- `render collection: @models`
31+
- `render partial: 'item', collection: @items`
32+
- `render partial: 'form', locals: {...}`
33+
34+
### Exhaustive Folder Traversal
35+
36+
The partial search traverses ALL folders in `app/views` recursively using `Dir.glob`, ensuring partials are found regardless of their location:
37+
- `app/views/collections/`
38+
- `app/views/collections/collection_questions/`
39+
- `app/views/items/`
40+
- `app/views/profiles/`
41+
- `app/views/loan_requests/`
42+
- Any other nested structure
43+
44+
This makes it a general solution that works for any Rails application structure. Overview
745

846
This guide explains how Rails Accessibility Testing works under the hood in simple terms.
947

docs_site/getting_started.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,12 @@ Rails Accessibility Testing runs **11 comprehensive checks** automatically. Thes
144144
1. **Form Labels** - All form inputs have associated labels
145145
2. **Image Alt Text** - All images have descriptive alt attributes
146146
3. **Interactive Elements** - Buttons, links have accessible names
147-
4. **Heading Hierarchy** - Proper h1-h6 structure without skipping levels
147+
4. **Heading Hierarchy** - Proper h1-h6 structure without skipping levels (checked across complete page: layout + view + partials)
148148
5. **Keyboard Accessibility** - All interactive elements are keyboard accessible
149-
6. **ARIA Landmarks** - Proper use of ARIA landmark roles
149+
6. **ARIA Landmarks** - Proper use of ARIA landmark roles (checked across complete page: layout + view + partials)
150150
7. **Form Error Associations** - Form errors are properly linked to form fields
151151
8. **Table Structure** - Tables have proper headers
152-
9. **Duplicate IDs** - No duplicate ID attributes
152+
9. **Duplicate IDs** - No duplicate ID attributes (checked across complete page: layout + view + partials)
153153
10. **Skip Links** - Skip navigation links present
154154
11. **Color Contrast** - Text meets WCAG contrast requirements (optional, disabled by default)
155155

docs_site/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Home
77

88
**The RSpec + RuboCop of accessibility for Rails. Catch WCAG violations before they reach production.**
99

10-
**Version:** 1.5.5
10+
**Version:** 1.5.9
1111

1212
Rails Accessibility Testing is a comprehensive, opinionated but configurable gem that makes accessibility testing as natural as unit testing. It integrates seamlessly into your Rails workflow, catching accessibility issues as you code—not after deployment.
1313

exe/a11y_live_scanner

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ begin
3535
require 'rails_accessibility_testing/config/yaml_loader'
3636
profile = defined?(Rails) && Rails.env.test? ? :test : :development
3737
config = RailsAccessibilityTesting::Config::YamlLoader.load(profile: profile)
38-
enabled = config.fetch('enabled', true)
38+
# Support both 'accessibility_enabled' (new) and 'enabled' (legacy) for backward compatibility
39+
enabled = config.fetch('accessibility_enabled', config.fetch('enabled', true))
3940
unless enabled
40-
puts "⏸️ Accessibility checks are disabled (enabled: false in config/accessibility.yml)"
41-
puts " Set enabled: true to enable accessibility scanning"
41+
puts "⏸️ Accessibility checks are disabled (accessibility_enabled: false in config/accessibility.yml)"
42+
puts " Set accessibility_enabled: true to enable accessibility scanning"
4243
puts " Scanner process will remain running but will not scan files"
4344
puts ""
4445
# Keep process alive so Foreman doesn't kill other processes

exe/a11y_static_scanner

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ begin
2929
require 'rails_accessibility_testing/config/yaml_loader'
3030
profile = defined?(Rails) && Rails.env.test? ? :test : :development
3131
config = RailsAccessibilityTesting::Config::YamlLoader.load(profile: profile)
32-
enabled = config.fetch('enabled', true)
32+
# Support both 'accessibility_enabled' (new) and 'enabled' (legacy) for backward compatibility
33+
enabled = config.fetch('accessibility_enabled', config.fetch('enabled', true))
3334
unless enabled
34-
puts "⏸️ Accessibility checks are disabled (enabled: false in config/accessibility.yml)"
35-
puts " Set enabled: true to enable accessibility scanning"
35+
puts "⏸️ Accessibility checks are disabled (accessibility_enabled: false in config/accessibility.yml)"
36+
puts " Set accessibility_enabled: true to enable accessibility scanning"
3637
puts " Scanner process will remain running but will not scan files"
3738
puts ""
3839
# Keep process alive so Foreman doesn't kill other processes

lib/generators/rails_a11y/install/templates/accessibility.yml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# This file configures accessibility checks for your Rails application.
44
# See https://github.com/your-org/rails-a11y for full documentation.
55

6-
# Global enable/disable flag
6+
# Global enable/disable flag for all accessibility checks
77
# Set to false to completely disable all accessibility checks (manual and automatic)
88
# When false, check_comprehensive_accessibility and automatic checks will be skipped
99
# Default: true
10-
enabled: true
10+
accessibility_enabled: true
1111

1212
# WCAG compliance level (A, AA, AAA)
1313
wcag_level: AA

lib/rails_accessibility_testing.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ module RailsAccessibilityTesting
5555
require_relative 'rails_accessibility_testing/violation_converter'
5656
require_relative 'rails_accessibility_testing/static_file_scanner'
5757
require_relative 'rails_accessibility_testing/static_scanning'
58+
require_relative 'rails_accessibility_testing/view_composition_builder'
59+
require_relative 'rails_accessibility_testing/composed_page_scanner'
5860
# Only load RSpec-specific components when RSpec is available
5961
if defined?(RSpec)
6062
require_relative 'rails_accessibility_testing/shared_examples'

0 commit comments

Comments
 (0)