Skip to content

Commit cea567c

Browse files
Docs: Add production deployment safety guide
- Add prominent production skipping section to README - Update configuration docs with production safety information - Add production safety section to website index page - Update all examples to show production-safe configuration - Link to Best Practices guide for detailed recommendations Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 6649b03 commit cea567c

3 files changed

Lines changed: 160 additions & 17 deletions

File tree

README.md

Lines changed: 71 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,64 @@ The gem automatically runs **11 comprehensive accessibility checks**:
289289

290290
## ⚙️ Configuration
291291

292+
### 🚨 Production Deployment Safety
293+
294+
**Important:** The gem is designed to be excluded from production environments. By default, accessibility tests are disabled to prevent them from running in production or blocking CI/CD pipelines.
295+
296+
#### Production Safety Features
297+
298+
1. **Disabled by Default** - `accessibility_enabled: false` prevents tests from running automatically
299+
2. **Production Guard** - Initializer includes `if defined?(RailsAccessibilityTesting)` check
300+
3. **Gem Exclusion** - Gem should be in `:development, :test` group only
301+
302+
#### Recommended Production Setup
303+
304+
**In your `Gemfile`:**
305+
```ruby
306+
group :development, :test do
307+
gem 'rails_accessibility_testing'
308+
# ... other test gems
309+
end
310+
```
311+
312+
**In `config/accessibility.yml`:**
313+
```yaml
314+
# Disabled by default - prevents CI/CD failures and production execution
315+
accessibility_enabled: false
316+
```
317+
318+
**In `config/initializers/rails_a11y.rb`:**
319+
```ruby
320+
# Production safety guard - prevents errors if gem not available
321+
if defined?(RailsAccessibilityTesting)
322+
RailsAccessibilityTesting.configure do |config|
323+
config.auto_run_checks = false
324+
end
325+
end
326+
```
327+
328+
**Why this matters:**
329+
- ✅ Prevents accessibility tests from blocking CI/CD pipelines
330+
- ✅ Safe deployment even if gem configuration exists
331+
- ✅ No errors if gem is excluded from production bundle
332+
- ✅ Manual testing available: `rspec spec/accessibility/all_pages_accessibility_spec.rb`
333+
334+
📖 **See [Best Practices Guide](GUIDES/best_practices.md) for detailed production configuration recommendations.**
335+
292336
### YAML Configuration
293337

294338
Create `config/accessibility.yml`:
295339

296340
```yaml
341+
# Global enable/disable flag for all accessibility checks
342+
# Set to false to completely disable all accessibility checks (manual and automatic)
343+
# When false, check_comprehensive_accessibility and automatic checks will be skipped
344+
# Default: false
345+
# (Set to false to allow other RSpec tests to pass in GitHub Actions CI even if accessibility tests fail.
346+
# When true, any failing accessibility tests will cause the entire CI pipeline to fail.)
347+
# Set to true to run accessibility checks manually: rspec spec/accessibility/all_pages_accessibility_spec.rb
348+
accessibility_enabled: false
349+
297350
# WCAG compliance level (A, AA, AAA)
298351
wcag_level: AA
299352
@@ -345,21 +398,28 @@ ignored_rules:
345398
Edit `config/initializers/rails_a11y.rb`:
346399

347400
```ruby
348-
RailsAccessibilityTesting.configure do |config|
349-
# Automatically run checks after system specs
350-
config.auto_run_checks = true
351-
352-
# Logger for accessibility check output
353-
config.logger = Rails.logger
354-
355-
# Configuration file path
356-
config.config_path = 'config/accessibility.yml'
401+
# Production safety guard - prevents errors if gem not available in production
402+
if defined?(RailsAccessibilityTesting)
403+
RailsAccessibilityTesting.configure do |config|
404+
# Automatically run checks after system specs
405+
# Set to false to disable automatic checks (recommended)
406+
config.auto_run_checks = false
407+
408+
# Logger for accessibility check output
409+
# Set to nil to use default logger
410+
# config.logger = Rails.logger
411+
412+
# Configuration file path (relative to Rails.root)
413+
# config.config_path = 'config/accessibility.yml'
357414
358-
# Default profile
359-
config.default_profile = :test
415+
# Default profile to use (development, test, ci)
416+
# config.default_profile = :test
417+
end
360418
end
361419
```
362420

421+
**Production Safety:** The `if defined?(RailsAccessibilityTesting)` guard ensures the configuration only loads if the gem is available, preventing errors in production environments where the gem may be excluded.
422+
363423
## 📋 Example Error Output
364424

365425
When accessibility issues are found, you get detailed, actionable errors with precise file locations:

docs_site/configuration.md

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,68 @@ You can customize how the gem works by creating a `config/accessibility.yml` fil
99

1010
---
1111

12+
## 🚨 Production Deployment Safety
13+
14+
**Important:** The gem is designed to be excluded from production environments. By default, accessibility tests are disabled to prevent them from running in production or blocking CI/CD pipelines.
15+
16+
### Production Safety Features
17+
18+
1. **Disabled by Default** - `accessibility_enabled: false` prevents tests from running automatically
19+
2. **Production Guard** - Initializer includes `if defined?(RailsAccessibilityTesting)` check
20+
3. **Gem Exclusion** - Gem should be in `:development, :test` group only
21+
22+
### Recommended Production Setup
23+
24+
**In your `Gemfile`:**
25+
```ruby
26+
group :development, :test do
27+
gem 'rails_accessibility_testing'
28+
# ... other test gems
29+
end
30+
```
31+
32+
**In `config/accessibility.yml`:**
33+
```yaml
34+
# Disabled by default - prevents CI/CD failures and production execution
35+
accessibility_enabled: false
36+
```
37+
38+
**In `config/initializers/rails_a11y.rb`:**
39+
```ruby
40+
# Production safety guard - prevents errors if gem not available
41+
if defined?(RailsAccessibilityTesting)
42+
RailsAccessibilityTesting.configure do |config|
43+
config.auto_run_checks = false
44+
end
45+
end
46+
```
47+
48+
**Why this matters:**
49+
- ✅ Prevents accessibility tests from blocking CI/CD pipelines
50+
- ✅ Safe deployment even if gem configuration exists
51+
- ✅ No errors if gem is excluded from production bundle
52+
- ✅ Manual testing available: `rspec spec/accessibility/all_pages_accessibility_spec.rb`
53+
54+
📖 **See [Best Practices Guide](https://github.com/rayraycodes/rails-accessibility-testing/blob/main/GUIDES/best_practices.md) for detailed production configuration recommendations.**
55+
56+
---
57+
1258
## Quick Start Configuration
1359

1460
Here is the configuration file structure that gets generated when you run the installer:
1561

1662
```yaml
1763
# config/accessibility.yml
1864
65+
# Global enable/disable flag for all accessibility checks
66+
# Set to false to completely disable all accessibility checks (manual and automatic)
67+
# When false, check_comprehensive_accessibility and automatic checks will be skipped
68+
# Default: false
69+
# (Set to false to allow other RSpec tests to pass in GitHub Actions CI even if accessibility tests fail.
70+
# When true, any failing accessibility tests will cause the entire CI pipeline to fail.)
71+
# Set to true to run accessibility checks manually: rspec spec/accessibility/all_pages_accessibility_spec.rb
72+
accessibility_enabled: false
73+
1974
# WCAG compliance level (A, AA, AAA)
2075
wcag_level: AA
2176
@@ -172,11 +227,27 @@ For advanced setup (like changing the logger), create an initializer:
172227

173228
```ruby
174229
# config/initializers/rails_a11y.rb
175-
RailsAccessibilityTesting.configure do |config|
176-
config.auto_run_checks = true # Note: Can be overridden by YAML config
177-
config.logger = Rails.logger
178-
config.default_profile = :test
230+
231+
# Production safety guard - prevents errors if gem not available in production
232+
if defined?(RailsAccessibilityTesting)
233+
RailsAccessibilityTesting.configure do |config|
234+
# Automatically run checks after system specs
235+
# Set to false to disable automatic checks (recommended)
236+
config.auto_run_checks = false # Note: Can be overridden by YAML config
237+
238+
# Logger for accessibility check output
239+
# Set to nil to use default logger
240+
# config.logger = Rails.logger
241+
242+
# Configuration file path (relative to Rails.root)
243+
# config.config_path = 'config/accessibility.yml'
244+
245+
# Default profile to use (development, test, ci)
246+
# config.default_profile = :test
247+
end
179248
end
180249
```
181250

251+
**Production Safety:** The `if defined?(RailsAccessibilityTesting)` guard ensures the configuration only loads if the gem is available, preventing errors in production environments where the gem may be excluded.
252+
182253
**Important:** The YAML `system_specs.auto_run` setting takes precedence over `config.auto_run_checks` from the initializer. Use YAML for environment-specific control.

docs_site/index.md

Lines changed: 14 additions & 2 deletions
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.6.0
10+
**Version:** 1.7.0
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

@@ -156,16 +156,28 @@ The gem automatically runs **11 comprehensive accessibility checks**:
156156
10.**Skip Links** - Skip navigation links present (detects various patterns)
157157
11.**Color Contrast** - Text meets contrast requirements (optional)
158158

159+
## 🚨 Production Deployment Safety
160+
161+
**Important:** The gem is designed to be excluded from production environments. By default, accessibility tests are disabled to prevent them from running in production or blocking CI/CD pipelines.
162+
163+
**Quick Setup:**
164+
- Add gem to `group :development, :test` in Gemfile
165+
- Set `accessibility_enabled: false` in `config/accessibility.yml`
166+
- Use production safety guard in initializer: `if defined?(RailsAccessibilityTesting)`
167+
168+
📖 **[See Configuration Guide]({{ '/configuration.html' | relative_url }})** for detailed production setup instructions.
169+
159170
## 📚 Documentation
160171

161172
- [Getting Started]({{ '/getting_started.html' | relative_url }}) - Quick start guide
162173
- [Architecture]({{ '/architecture.html' | relative_url }}) - Visual diagrams and internal architecture
163-
- [Configuration]({{ '/configuration.html' | relative_url }}) - Configuration options
174+
- [Configuration]({{ '/configuration.html' | relative_url }}) - **Production safety & configuration options**
164175
- [CI Integration]({{ '/ci_integration.html' | relative_url }}) - CI/CD setup
165176
- [Contributing]({{ '/contributing.html' | relative_url }}) - How to contribute
166177

167178
### Additional Guides
168179

180+
- [Best Practices](https://github.com/rayraycodes/rails-accessibility-testing/blob/main/GUIDES/best_practices.md) - ⭐ **Production-tested configuration patterns**
169181
- [System Specs for Accessibility](https://github.com/rayraycodes/rails-accessibility-testing/blob/main/GUIDES/system_specs_for_accessibility.md) - ⭐ Recommended approach
170182
- [Writing Accessible Views](https://github.com/rayraycodes/rails-accessibility-testing/blob/main/GUIDES/writing_accessible_views_in_rails.md) - Best practices
171183
- [Working with Designers](https://github.com/rayraycodes/rails-accessibility-testing/blob/main/GUIDES/working_with_designers_and_content_authors.md) - Team collaboration

0 commit comments

Comments
 (0)