rails_accessibility_testing 1.5.5 → 1.5.6
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 +336 -71
- data/CHANGELOG.md +17 -0
- data/GUIDES/getting_started.md +46 -177
- data/README.md +4 -0
- data/docs_site/_config.yml +3 -0
- data/docs_site/_layouts/default.html +95 -588
- data/docs_site/architecture.md +98 -469
- data/docs_site/ci_integration.md +87 -32
- data/docs_site/configuration.md +119 -51
- data/docs_site/contributing.md +166 -6
- data/docs_site/favicon.svg +31 -0
- data/docs_site/getting_started.md +188 -66
- data/docs_site/index.md +136 -21
- data/lib/generators/rails_a11y/install/templates/accessibility.yml.erb +16 -0
- data/lib/rails_accessibility_testing/accessibility_helper.rb +86 -16
- data/lib/rails_accessibility_testing/checks/base_check.rb +32 -5
- data/lib/rails_accessibility_testing/checks/interactive_elements_check.rb +23 -0
- data/lib/rails_accessibility_testing/config/yaml_loader.rb +9 -0
- data/lib/rails_accessibility_testing/error_message_builder.rb +28 -0
- data/lib/rails_accessibility_testing/rspec_integration.rb +25 -1
- 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: 8d34d5660b977262210b74a73348efd1d44742645bd5025032727d116ff3fae2
|
|
4
|
+
data.tar.gz: d8fc5768263b21a5f2b4521b9b8f898bc90ed50c9477640ca4d2597a88b39010
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cd65e152bec83806b8c1205b03b51b85ebcc9befddc8d7d3f97c0e4c77aff50ab8969a8abe21d32f4e59967e17f751e731ebd2484e49125bc05bd2079a7c2598
|
|
7
|
+
data.tar.gz: 9cca616fa74d3d9eb79ce5930fc5b46c37774f7a99cd1bc76caa2f35a9e5e65084e30a748d72d21ce024437cfd07c6ba69af6f00978eb0c068b1133671a9e03d
|
data/ARCHITECTURE.md
CHANGED
|
@@ -170,12 +170,14 @@ graph TB
|
|
|
170
170
|
CLI --> RuleEngine
|
|
171
171
|
Routes --> ViewDetector
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
StaticScanner --> FileTracker[FileChangeTracker]
|
|
174
|
+
StaticScanner --> ErbExtractor
|
|
175
|
+
ErbExtractor --> StaticAdapter[StaticPageAdapter]
|
|
176
|
+
StaticAdapter --> RuleEngine
|
|
177
|
+
StaticScanner --> LineFinder[LineNumberFinder]
|
|
178
|
+
StaticScanner --> ViolationConverter[ViolationConverter]
|
|
179
|
+
ViolationConverter --> LineFinder
|
|
180
|
+
ViolationConverter --> ErrorBuilder
|
|
179
181
|
|
|
180
182
|
style Entry fill:#ff6b6b
|
|
181
183
|
style RuleEngine fill:#4ecdc4
|
|
@@ -427,91 +429,353 @@ graph TB
|
|
|
427
429
|
- **Subsequent Runs**: Only tests changed files
|
|
428
430
|
- **Force Option**: `TEST_ALL_PAGES=true` environment variable
|
|
429
431
|
|
|
430
|
-
### Static Scanning System (NEW in 1.5.3)
|
|
432
|
+
### Static Scanning System (NEW in 1.5.3+)
|
|
431
433
|
|
|
432
|
-
The static scanning system allows scanning view files directly without browser rendering, providing fast feedback during development.
|
|
434
|
+
The static scanning system allows scanning view files directly without browser rendering, providing fast feedback during development. It's the recommended approach for continuous development testing via `bin/dev`.
|
|
435
|
+
|
|
436
|
+
#### Architecture Overview
|
|
437
|
+
|
|
438
|
+
The static scanner uses a modular, pipeline-based architecture:
|
|
439
|
+
|
|
440
|
+
```
|
|
441
|
+
ERB Template → ErbExtractor → HTML → StaticPageAdapter → RuleEngine → Checks → Violations → ViolationConverter → Errors/Warnings
|
|
442
|
+
```
|
|
433
443
|
|
|
434
444
|
#### Components
|
|
435
445
|
|
|
436
446
|
1. **StaticFileScanner** - Main orchestrator
|
|
437
|
-
- Reads ERB template files
|
|
438
|
-
- Coordinates
|
|
439
|
-
-
|
|
447
|
+
- Reads ERB template files from `app/views/**/*.html.erb`
|
|
448
|
+
- Coordinates the entire scanning pipeline
|
|
449
|
+
- Loads configuration via `YamlLoader`
|
|
450
|
+
- Creates `RuleEngine` instance with config
|
|
451
|
+
- Returns structured hash: `{ errors: [...], warnings: [...] }`
|
|
440
452
|
|
|
441
453
|
2. **FileChangeTracker** - Change detection for static files
|
|
442
|
-
-
|
|
443
|
-
-
|
|
444
|
-
-
|
|
454
|
+
- **State File**: `tmp/.rails_a11y_scanned_files.json`
|
|
455
|
+
- **Purpose**: Tracks file modification times (mtime) to detect changes
|
|
456
|
+
- **Methods**:
|
|
457
|
+
- `load_state`: Reads JSON state file, returns hash of `{ file_path => mtime }`
|
|
458
|
+
- `changed_files(files)`: Compares current mtimes with stored state, returns changed/new files
|
|
459
|
+
- `update_state(files)`: Updates state file with current mtimes (atomic write)
|
|
460
|
+
- `clear_state`: Clears state file (forces full rescan)
|
|
461
|
+
- **Atomic Writes**: Uses temp file + `mv` to prevent partial writes
|
|
445
462
|
|
|
446
463
|
3. **ErbExtractor** - ERB to HTML conversion
|
|
447
|
-
- Converts Rails helpers
|
|
448
|
-
-
|
|
449
|
-
|
|
464
|
+
- **Purpose**: Converts Rails helpers to HTML placeholders for static analysis
|
|
465
|
+
- **Supported Helpers**:
|
|
466
|
+
- Form: `select_tag`, `text_field_tag`, `password_field_tag`, `email_field_tag`, `text_area_tag`, `check_box_tag`, `radio_button_tag`, `label_tag`, `form_with`, `form_for`
|
|
467
|
+
- Images: `image_tag`
|
|
468
|
+
- Links: `link_to` (with/without blocks, with/without text)
|
|
469
|
+
- Buttons: `button_tag`, `f.submit`, `button`
|
|
470
|
+
- **Process**:
|
|
471
|
+
1. Convert Rails helpers to HTML (preserves attributes: id, name, src, alt, href)
|
|
472
|
+
2. Remove ERB tags (`<% ... %>`, `<%= ... %>`)
|
|
473
|
+
3. Clean up whitespace
|
|
474
|
+
- **Limitations**: Cannot execute Ruby code, only converts helpers to placeholders
|
|
450
475
|
|
|
451
476
|
4. **StaticPageAdapter** - Capybara compatibility layer
|
|
452
|
-
- Makes Nokogiri documents look like Capybara pages
|
|
453
|
-
-
|
|
454
|
-
|
|
477
|
+
- **Purpose**: Makes Nokogiri documents look like Capybara pages
|
|
478
|
+
- **Key Methods**:
|
|
479
|
+
- `all(selector, visible: true)`: Returns array of `StaticElementAdapter` instances
|
|
480
|
+
- `has_css?(selector, wait: true)`: Checks if selector exists
|
|
481
|
+
- `current_url`, `current_path`: Returns `nil` (not applicable)
|
|
482
|
+
- **StaticElementAdapter**: Wraps Nokogiri elements to look like Capybara elements
|
|
483
|
+
- `tag_name`, `[]`, `text`, `visible?`, `all(selector)`, `find(:xpath, '..')`
|
|
484
|
+
- **Benefit**: Allows reuse of existing checks without modification
|
|
455
485
|
|
|
456
486
|
5. **LineNumberFinder** - Precise error location
|
|
457
|
-
- Maps HTML elements back to original ERB line numbers
|
|
458
|
-
-
|
|
459
|
-
|
|
487
|
+
- **Purpose**: Maps HTML elements back to original ERB line numbers
|
|
488
|
+
- **Matching Strategy** (in order of specificity):
|
|
489
|
+
1. Match by `id` attribute (most specific)
|
|
490
|
+
2. Match by `src` attribute (for images)
|
|
491
|
+
3. Match by `href` attribute (for links)
|
|
492
|
+
4. Match by `type` attribute (for inputs)
|
|
493
|
+
5. Match by tag name (fallback)
|
|
494
|
+
- **Returns**: 1-indexed line number or `nil` if not found
|
|
460
495
|
|
|
461
496
|
6. **ViolationConverter** - Result formatting
|
|
462
|
-
- Converts raw
|
|
463
|
-
-
|
|
464
|
-
|
|
497
|
+
- **Purpose**: Converts raw `Violation` objects to structured errors/warnings
|
|
498
|
+
- **Process**:
|
|
499
|
+
1. Iterates through violations from `RuleEngine`
|
|
500
|
+
2. Uses `LineNumberFinder` to find line numbers
|
|
501
|
+
3. Categorizes as error or warning (based on `warning?` method)
|
|
502
|
+
4. Filters warnings if `ignore_warnings: true` in config
|
|
503
|
+
5. Returns `{ errors: [...], warnings: [...] }`
|
|
504
|
+
- **Warning Detection**:
|
|
505
|
+
- Skip links → warnings (best practice, not required)
|
|
506
|
+
- ARIA landmarks → warnings (best practice, not always required)
|
|
507
|
+
- Everything else → errors
|
|
508
|
+
|
|
509
|
+
#### Complete Static Scanner Flow
|
|
510
|
+
|
|
511
|
+
```mermaid
|
|
512
|
+
graph TB
|
|
513
|
+
Start[a11y_static_scanner Startup] --> LoadConfig[Load accessibility.yml]
|
|
514
|
+
LoadConfig --> LoadState[FileChangeTracker.load_state]
|
|
515
|
+
LoadState --> GetFiles[Get all view files<br/>app/views/**/*.html.erb]
|
|
516
|
+
GetFiles --> Decision{scan_changed_only?}
|
|
517
|
+
|
|
518
|
+
Decision -->|false| ScanAll[Scan ALL files]
|
|
519
|
+
Decision -->|true| CheckStartup{full_scan_on_startup?}
|
|
520
|
+
|
|
521
|
+
CheckStartup -->|true| ScanAll
|
|
522
|
+
CheckStartup -->|false| CheckChanged[FileChangeTracker.changed_files]
|
|
523
|
+
|
|
524
|
+
CheckChanged --> ChangedEmpty{Changed files empty?}
|
|
525
|
+
ChangedEmpty -->|yes| WatchLoop[Enter watch loop<br/>sleep check_interval]
|
|
526
|
+
ChangedEmpty -->|no| ScanChanged[Scan changed files only]
|
|
527
|
+
|
|
528
|
+
ScanAll --> ScanFile[For each file:<br/>StaticFileScanner.scan]
|
|
529
|
+
ScanChanged --> ScanFile
|
|
530
|
+
|
|
531
|
+
ScanFile --> ReadFile[Read ERB file content]
|
|
532
|
+
ReadFile --> Extract[ErbExtractor.extract_html]
|
|
533
|
+
Extract --> Parse[Nokogiri.parse HTML]
|
|
534
|
+
Parse --> Adapter[StaticPageAdapter.new]
|
|
535
|
+
Adapter --> LoadConfig2[YamlLoader.load profile: :test]
|
|
536
|
+
LoadConfig2 --> Engine[RuleEngine.new config: config]
|
|
537
|
+
Engine --> RunChecks[Run all 11 enabled checks]
|
|
538
|
+
RunChecks --> Collect[Collect violations]
|
|
539
|
+
Collect --> Convert[ViolationConverter.convert]
|
|
540
|
+
Convert --> FindLines[LineNumberFinder.find_line_number]
|
|
541
|
+
FindLines --> Filter{ignore_warnings?}
|
|
542
|
+
Filter -->|true| RemoveWarnings[Remove warnings]
|
|
543
|
+
Filter -->|false| KeepAll[Keep errors + warnings]
|
|
544
|
+
RemoveWarnings --> Format[Format errors/warnings]
|
|
545
|
+
KeepAll --> Format
|
|
546
|
+
Format --> UpdateState[FileChangeTracker.update_state]
|
|
547
|
+
UpdateState --> Output[Display results]
|
|
548
|
+
|
|
549
|
+
Output --> Continuous{scan_changed_only?}
|
|
550
|
+
Continuous -->|true| WatchLoop
|
|
551
|
+
Continuous -->|false| Exit[Exit]
|
|
552
|
+
|
|
553
|
+
WatchLoop --> Sleep[sleep check_interval]
|
|
554
|
+
Sleep --> CheckAgain[FileChangeTracker.changed_files]
|
|
555
|
+
CheckAgain --> HasChanges{Has changes?}
|
|
556
|
+
HasChanges -->|yes| ScanChanged
|
|
557
|
+
HasChanges -->|no| Sleep
|
|
558
|
+
|
|
559
|
+
style Start fill:#ff6b6b
|
|
560
|
+
style ScanFile fill:#4ecdc4
|
|
561
|
+
style Extract fill:#ff9ff3
|
|
562
|
+
style Adapter fill:#48dbfb
|
|
563
|
+
style Engine fill:#feca57
|
|
564
|
+
style FindLines fill:#ff6b6b
|
|
565
|
+
style Format fill:#ffeaa7
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
#### File Selection Logic
|
|
465
569
|
|
|
466
|
-
|
|
570
|
+
The static scanner uses a sophisticated file selection algorithm based on configuration flags:
|
|
467
571
|
|
|
468
572
|
```mermaid
|
|
469
573
|
graph TB
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
574
|
+
Start[Scanner Startup] --> Config[Load Config]
|
|
575
|
+
Config --> Flags{Read Flags}
|
|
576
|
+
Flags --> ScanChanged[scan_changed_only]
|
|
577
|
+
Flags --> FullStartup[full_scan_on_startup]
|
|
578
|
+
|
|
579
|
+
ScanChanged -->|false| AlwaysScan[Scan ALL files every time]
|
|
580
|
+
ScanChanged -->|true| CheckStartup{full_scan_on_startup?}
|
|
581
|
+
|
|
582
|
+
CheckStartup -->|true| StartupScan[Scan ALL files on startup]
|
|
583
|
+
CheckStartup -->|false| ChangedOnly[Only scan changed files]
|
|
584
|
+
|
|
585
|
+
StartupScan --> AfterStartup[After startup scan completes]
|
|
586
|
+
ChangedOnly --> CheckEmpty{Any changed files?}
|
|
587
|
+
|
|
588
|
+
CheckEmpty -->|no| WatchMode[Enter watch mode<br/>Check every check_interval seconds]
|
|
589
|
+
CheckEmpty -->|yes| ScanChangedFiles[Scan changed files]
|
|
590
|
+
|
|
591
|
+
AfterStartup --> WatchMode
|
|
592
|
+
ScanChangedFiles --> WatchMode
|
|
593
|
+
|
|
594
|
+
WatchMode --> Sleep[sleep check_interval]
|
|
595
|
+
Sleep --> CheckChanges[FileChangeTracker.changed_files]
|
|
596
|
+
CheckChanges --> HasChanges{Has changes?}
|
|
597
|
+
HasChanges -->|yes| ScanChangedFiles
|
|
598
|
+
HasChanges -->|no| Sleep
|
|
599
|
+
|
|
600
|
+
AlwaysScan --> Done[Exit after scan]
|
|
601
|
+
|
|
602
|
+
style StartupScan fill:#55efc4
|
|
603
|
+
style ScanChangedFiles fill:#fdcb6e
|
|
604
|
+
style WatchMode fill:#a29bfe
|
|
488
605
|
```
|
|
489
606
|
|
|
490
|
-
#### Configuration
|
|
607
|
+
#### Configuration Flags Reference
|
|
608
|
+
|
|
609
|
+
All configuration is done via `config/accessibility.yml`:
|
|
610
|
+
|
|
611
|
+
##### Static Scanner Configuration (`static_scanner`)
|
|
612
|
+
|
|
613
|
+
| Flag | Type | Default | Description |
|
|
614
|
+
|------|------|---------|-------------|
|
|
615
|
+
| `scan_changed_only` | Boolean | `true` | Only scan files that have changed since last scan. When `false`, scans all files every time. |
|
|
616
|
+
| `check_interval` | Integer | `3` | Seconds between file change checks when running continuously. Only used when `scan_changed_only: true`. |
|
|
617
|
+
| `full_scan_on_startup` | Boolean | `true` | Force full scan of all files on startup. When `false`, only scans changed files from the start. |
|
|
618
|
+
|
|
619
|
+
**Flag Interaction Matrix:**
|
|
620
|
+
|
|
621
|
+
| `scan_changed_only` | `full_scan_on_startup` | Behavior |
|
|
622
|
+
|---------------------|------------------------|---------|
|
|
623
|
+
| `false` | `true`/`false` | Scan all files every time, exit after scan |
|
|
624
|
+
| `true` | `true` | Scan all files on startup, then watch for changes |
|
|
625
|
+
| `true` | `false` | Only scan changed files, watch for changes |
|
|
626
|
+
|
|
627
|
+
##### Summary Configuration (`summary`)
|
|
628
|
+
|
|
629
|
+
| Flag | Type | Default | Description |
|
|
630
|
+
|------|------|---------|-------------|
|
|
631
|
+
| `show_summary` | Boolean | `true` | Show summary at end of test suite (RSpec only) |
|
|
632
|
+
| `errors_only` | Boolean | `false` | Show only errors in summary, hide warnings (RSpec only) |
|
|
633
|
+
| `show_fixes` | Boolean | `true` | Show fix suggestions in error messages |
|
|
634
|
+
| `ignore_warnings` | Boolean | `false` | **Filter out warnings completely** - only show errors. Used by both static scanner and RSpec. |
|
|
635
|
+
|
|
636
|
+
**Warning Filtering:**
|
|
637
|
+
- `ignore_warnings: true` → Warnings are filtered out at `ViolationConverter` level
|
|
638
|
+
- `errors_only: true` → Warnings are hidden in summary but still collected (RSpec only)
|
|
639
|
+
|
|
640
|
+
##### Check Configuration (`checks`)
|
|
491
641
|
|
|
492
|
-
|
|
642
|
+
| Check | Default | Description |
|
|
643
|
+
|-------|---------|-------------|
|
|
644
|
+
| `form_labels` | `true` | Form inputs have associated labels |
|
|
645
|
+
| `image_alt_text` | `true` | Images have alt attributes |
|
|
646
|
+
| `interactive_elements` | `true` | Interactive elements have accessible names |
|
|
647
|
+
| `heading` | `true` | Proper heading hierarchy |
|
|
648
|
+
| `keyboard_accessibility` | `true` | Elements are keyboard accessible |
|
|
649
|
+
| `aria_landmarks` | `true` | Proper ARIA landmark roles |
|
|
650
|
+
| `form_errors` | `true` | Form errors linked to fields |
|
|
651
|
+
| `table_structure` | `true` | Tables have proper headers |
|
|
652
|
+
| `duplicate_ids` | `true` | No duplicate IDs |
|
|
653
|
+
| `skip_links` | `true` | Skip navigation links present |
|
|
654
|
+
| `color_contrast` | `false` | Text meets contrast requirements (expensive) |
|
|
655
|
+
|
|
656
|
+
##### Profile-Specific Configuration
|
|
657
|
+
|
|
658
|
+
Configuration supports profiles (`development`, `test`, `ci`) with deep merging:
|
|
493
659
|
|
|
494
660
|
```yaml
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
#
|
|
504
|
-
|
|
505
|
-
|
|
661
|
+
# Base config
|
|
662
|
+
wcag_level: AA
|
|
663
|
+
checks:
|
|
664
|
+
color_contrast: false
|
|
665
|
+
|
|
666
|
+
# Profile-specific (deep merged)
|
|
667
|
+
development:
|
|
668
|
+
checks:
|
|
669
|
+
color_contrast: false # Overrides base
|
|
670
|
+
static_scanner:
|
|
671
|
+
check_interval: 5 # Overrides base
|
|
672
|
+
|
|
673
|
+
ci:
|
|
674
|
+
checks:
|
|
675
|
+
color_contrast: true # Overrides base
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
**Merging Rules:**
|
|
679
|
+
- Base config + Profile config = Merged config
|
|
680
|
+
- Checks are merged (profile overrides base)
|
|
681
|
+
- Summary config is merged (profile overrides base)
|
|
682
|
+
- Static scanner config is merged (profile overrides base)
|
|
683
|
+
- `ignored_rules` are concatenated and deduplicated
|
|
684
|
+
|
|
685
|
+
#### Data Flow: ERB to Error Report
|
|
686
|
+
|
|
687
|
+
```mermaid
|
|
688
|
+
sequenceDiagram
|
|
689
|
+
participant Scanner as StaticFileScanner
|
|
690
|
+
participant File as ERB File
|
|
691
|
+
participant Extractor as ErbExtractor
|
|
692
|
+
participant Nokogiri as Nokogiri Parser
|
|
693
|
+
participant Adapter as StaticPageAdapter
|
|
694
|
+
participant Config as YamlLoader
|
|
695
|
+
participant Engine as RuleEngine
|
|
696
|
+
participant Check as Check (e.g., FormLabelsCheck)
|
|
697
|
+
participant Collector as ViolationCollector
|
|
698
|
+
participant Converter as ViolationConverter
|
|
699
|
+
participant Finder as LineNumberFinder
|
|
700
|
+
participant Output as CLI Output
|
|
701
|
+
|
|
702
|
+
Scanner->>File: Read file content
|
|
703
|
+
File-->>Scanner: ERB template string
|
|
704
|
+
|
|
705
|
+
Scanner->>Extractor: extract_html(content)
|
|
706
|
+
Extractor->>Extractor: Convert Rails helpers to HTML
|
|
707
|
+
Extractor->>Extractor: Remove ERB tags
|
|
708
|
+
Extractor-->>Scanner: HTML string
|
|
709
|
+
|
|
710
|
+
Scanner->>Nokogiri: Parse HTML
|
|
711
|
+
Nokogiri-->>Scanner: Nokogiri::Document
|
|
712
|
+
|
|
713
|
+
Scanner->>Adapter: new(html, view_file: path)
|
|
714
|
+
Adapter-->>Scanner: StaticPageAdapter instance
|
|
715
|
+
|
|
716
|
+
Scanner->>Config: load(profile: :test)
|
|
717
|
+
Config-->>Scanner: Config hash with checks, summary, static_scanner
|
|
718
|
+
|
|
719
|
+
Scanner->>Engine: new(config: config)
|
|
720
|
+
Engine-->>Scanner: RuleEngine instance
|
|
721
|
+
|
|
722
|
+
Scanner->>Engine: check(static_page, context: { view_file })
|
|
723
|
+
|
|
724
|
+
loop For each enabled check
|
|
725
|
+
Engine->>Check: new(page: static_page, context: context)
|
|
726
|
+
Check->>Adapter: all('input[type="text"]')
|
|
727
|
+
Adapter-->>Check: Array of StaticElementAdapter
|
|
728
|
+
Check->>Check: Validate WCAG rules
|
|
729
|
+
Check-->>Engine: Array of Violations
|
|
730
|
+
Engine->>Collector: add(violations)
|
|
731
|
+
end
|
|
732
|
+
|
|
733
|
+
Engine-->>Scanner: Array of Violation objects
|
|
734
|
+
|
|
735
|
+
Scanner->>Finder: new(file_content)
|
|
736
|
+
Finder-->>Scanner: LineNumberFinder instance
|
|
737
|
+
|
|
738
|
+
Scanner->>Converter: convert(violations, view_file, finder, config)
|
|
739
|
+
|
|
740
|
+
loop For each violation
|
|
741
|
+
Converter->>Finder: find_line_number(element_context)
|
|
742
|
+
Finder-->>Converter: Line number (1-indexed)
|
|
743
|
+
Converter->>Converter: Categorize as error/warning
|
|
744
|
+
Converter->>Converter: Filter warnings if ignore_warnings: true
|
|
745
|
+
end
|
|
746
|
+
|
|
747
|
+
Converter-->>Scanner: { errors: [...], warnings: [...] }
|
|
748
|
+
|
|
749
|
+
Scanner->>Output: Display formatted errors
|
|
750
|
+
Output->>Output: Show file path, line number, error type
|
|
506
751
|
```
|
|
507
752
|
|
|
753
|
+
#### Integration Points
|
|
754
|
+
|
|
755
|
+
1. **RuleEngine Integration**
|
|
756
|
+
- Static scanner uses the same `RuleEngine` as system specs
|
|
757
|
+
- All 11 checks work identically for both static and dynamic scanning
|
|
758
|
+
- Configuration (`checks`, `ignored_rules`) applies to both
|
|
759
|
+
|
|
760
|
+
2. **Configuration Integration**
|
|
761
|
+
- `YamlLoader` loads config with profile support
|
|
762
|
+
- Static scanner uses `profile: :test` (can be changed)
|
|
763
|
+
- Summary config (`ignore_warnings`) applies to both static scanner and RSpec
|
|
764
|
+
|
|
765
|
+
3. **File Change Tracking**
|
|
766
|
+
- State file: `tmp/.rails_a11y_scanned_files.json`
|
|
767
|
+
- Format: `{ "app/views/pages/home.html.erb": 1234567890.123 }`
|
|
768
|
+
- Atomic writes prevent corruption
|
|
769
|
+
- Automatically cleaned up (removes deleted files)
|
|
770
|
+
|
|
508
771
|
#### Benefits
|
|
509
772
|
|
|
510
|
-
- **Fast**: No browser needed - scans ERB templates directly
|
|
773
|
+
- **Fast**: No browser needed - scans ERB templates directly (~10-100x faster than browser-based)
|
|
511
774
|
- **Precise**: Reports exact file locations and line numbers
|
|
512
775
|
- **Efficient**: Only scans changed files using modification time tracking
|
|
513
776
|
- **Continuous**: Runs continuously, watching for file changes
|
|
514
777
|
- **Reusable**: Leverages existing RuleEngine and all 11 checks
|
|
778
|
+
- **Configurable**: Full control via YAML with profile support
|
|
515
779
|
|
|
516
780
|
#### Performance Optimization Flow
|
|
517
781
|
|
|
@@ -776,7 +1040,7 @@ ci:
|
|
|
776
1040
|
|
|
777
1041
|
---
|
|
778
1042
|
|
|
779
|
-
## Version 1.5.
|
|
1043
|
+
## Version 1.5.3+ Highlights
|
|
780
1044
|
|
|
781
1045
|
### New Components
|
|
782
1046
|
|
|
@@ -785,13 +1049,13 @@ ci:
|
|
|
785
1049
|
3. **Enhanced ChangeDetector**: Asset change detection and smart partial impact analysis
|
|
786
1050
|
4. **Improved View File Detection**: Fuzzy matching and controller directory scanning
|
|
787
1051
|
5. **Rails Server Safe Wrapper**: Prevents Foreman from terminating processes
|
|
788
|
-
6. **Static Scanning System**: File-based scanning without browser (NEW in 1.5.
|
|
789
|
-
- **StaticFileScanner**: Main orchestrator for static file scanning
|
|
790
|
-
- **FileChangeTracker**: Tracks file modification times
|
|
791
|
-
- **ErbExtractor**: Converts ERB templates to HTML
|
|
1052
|
+
6. **Static Scanning System**: File-based scanning without browser (NEW in 1.5.3+)
|
|
1053
|
+
- **StaticFileScanner**: Main orchestrator for static file scanning pipeline
|
|
1054
|
+
- **FileChangeTracker**: Tracks file modification times in `tmp/.rails_a11y_scanned_files.json`
|
|
1055
|
+
- **ErbExtractor**: Converts ERB templates to HTML (15+ Rails helpers supported)
|
|
792
1056
|
- **StaticPageAdapter**: Makes Nokogiri documents compatible with existing checks
|
|
793
|
-
- **LineNumberFinder**: Maps HTML elements to ERB line numbers
|
|
794
|
-
- **ViolationConverter**: Formats violations with precise file locations
|
|
1057
|
+
- **LineNumberFinder**: Maps HTML elements to ERB line numbers (1-indexed)
|
|
1058
|
+
- **ViolationConverter**: Formats violations with precise file locations, respects `ignore_warnings`
|
|
795
1059
|
|
|
796
1060
|
### Enhanced Components
|
|
797
1061
|
|
|
@@ -807,9 +1071,10 @@ ci:
|
|
|
807
1071
|
2. **Smart Change Detection**: Only tests affected pages
|
|
808
1072
|
3. **First-Run Optimization**: Faster initial setup
|
|
809
1073
|
4. **Reduced Wait Times**: Faster Capybara operations
|
|
810
|
-
5. **Static File Scanning**: Fast file-based scanning without browser overhead (
|
|
811
|
-
6. **File Change Tracking**: Only scans modified files using modification time tracking
|
|
812
|
-
7. **Continuous Monitoring**: Watches for file changes and re-scans automatically
|
|
1074
|
+
5. **Static File Scanning**: Fast file-based scanning without browser overhead (~10-100x faster)
|
|
1075
|
+
6. **File Change Tracking**: Only scans modified files using modification time tracking (`FileChangeTracker`)
|
|
1076
|
+
7. **Continuous Monitoring**: Watches for file changes and re-scans automatically (configurable via `check_interval`)
|
|
1077
|
+
8. **Configuration Flags**: Comprehensive YAML configuration with profile support (`scan_changed_only`, `full_scan_on_startup`, `ignore_warnings`, etc.)
|
|
813
1078
|
|
|
814
1079
|
---
|
|
815
1080
|
|
|
@@ -837,5 +1102,5 @@ ci:
|
|
|
837
1102
|
|
|
838
1103
|
---
|
|
839
1104
|
|
|
840
|
-
**Architecture Version**: 1.5.
|
|
841
|
-
**Last Updated**: 2025-11-
|
|
1105
|
+
**Architecture Version**: 1.5.5
|
|
1106
|
+
**Last Updated**: 2025-11-20
|
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
|
+
## [1.5.6] - 2024-12-01
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **System specs auto-run default**: Changed default `system_specs.auto_run` to `false` in YAML configuration
|
|
12
|
+
- **Breaking change**: Accessibility checks no longer run automatically in system specs by default
|
|
13
|
+
- **Migration**: Users who want automatic checks should set `system_specs.auto_run: true` in their `config/accessibility.yml`
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- **H2 inside button detection**: Added check for headings nested inside button elements (accessibility violation)
|
|
17
|
+
- **Improved view file detection**: Better prioritization of view files vs layout files for error attribution
|
|
18
|
+
- **YAML configuration for system specs**: Added `system_specs.auto_run` configuration option in YAML
|
|
19
|
+
|
|
20
|
+
### Improved
|
|
21
|
+
- **Error reporting**: Improved accuracy of error attribution to correct view files based on Rails HTML structure
|
|
22
|
+
- **Layout detection**: Better detection of layout elements vs yield content (view files)
|
|
23
|
+
- **System spec output**: Reduced terminal clutter by only showing errors, not success messages
|
|
24
|
+
|
|
8
25
|
## [1.5.5] - 2024-11-20
|
|
9
26
|
|
|
10
27
|
### Fixed
|