Commit c3821b8
fix(loader): require "guardrails/configuration" from the top-level entry
Local-build verification (gem build → install in sandbox → require
"guardrails") surfaced that `Guardrails.configure` was undefined
unless a caller also `require`d `guardrails/configuration` themselves.
That's exactly what an embedded user's
`config/initializers/guardrails.rb` would NOT do — Rails autoloads
the initializer after `require "guardrails"` and no other code path
pulls in Configuration unless the rake task does (which doesn't run
at boot). So `Guardrails.configure { |c| c.visual_diff.enabled = true }`
in an initializer NoMethodErrors on first app boot.
Fix: require "guardrails/configuration" from `lib/guardrails.rb`.
Two-line addition, no behavior change for anyone who was already
requiring detector files directly.
Regression spec in `spec/guardrails_spec.rb` locks the contract:
asserts both Guardrails.configure and .configuration are callable
after `require "guardrails"` alone, and the block actually sets
the values.
Worth noting this slipped past 459 specs because every previous
visual_diff/configuration spec explicitly `require`d both files.
The actual user code path (initializer-only require) wasn't
covered until now.
Full suite 461/461 (up from 459).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6bce923 commit c3821b8
2 files changed
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
4 | 10 | | |
5 | 11 | | |
6 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
7 | 30 | | |
0 commit comments