You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compliance test runs only for eager loaded files. Therefore, in order to verify Zeitwerk compliance, it is recommended to have all autoload paths in the eager load paths.
104
+
105
+
This is already the case by default, but if the project has custom autoload paths configured just like this:
106
+
107
+
```ruby
108
+
config.autoload_paths <<"#{Rails.root}/extras"
109
+
```
110
+
111
+
those are not eager loaded and won't be verified. Adding them to the eager load paths is easy:
112
+
113
+
```ruby
114
+
config.autoload_paths <<"#{Rails.root}/extras"
115
+
config.eager_load_paths <<"#{Rails.root}/extras"
116
+
```
117
+
118
+
### zeitwerk:check
119
+
120
+
Once `zeitwerk` mode is enabled and the configuration of eager load paths double-checked, please run:
102
121
103
122
```
104
123
bin/rails zeitwerk:check
@@ -114,7 +133,9 @@ All is good!
114
133
115
134
There can be additional output depending on the application configuration, but the last "All is good!" is what you are looking for.
116
135
117
-
If there's any file that does not define the expected constant, the task will tell you. It does so one file at a time, because if it moved on, the failure loading one file could cascade into other failures unrelated to the check we want to run and the error report would be confusing.
136
+
If the double-check explained in the previous section determined actually there have to be some custom autoload paths outside the eager load paths, the task will detect and warn about them. However, if the test suite loads those files successfully, you're good.
137
+
138
+
Now, if there's any file that does not define the expected constant, the task will tell you. It does so one file at a time, because if it moved on, the failure loading one file could cascade into other failures unrelated to the check we want to run and the error report would be confusing.
118
139
119
140
If there's one constant reported, fix that particular one and run the task again. Repeat until you get "All is good!".
120
141
@@ -145,15 +166,15 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
145
166
end
146
167
```
147
168
148
-
Doing so affects how Active Support inflects globally. That may be fine, but if you prefer you can also pass overrides to the inflector used by the autoloader:
169
+
Doing so affects how Active Support inflects globally. That may be fine, but if you prefer you can also pass overrides to the inflectors used by the autoloaders:
With this option you have more control, because only files called exactly `vat.rb` or directories exactly called `vat` will be inflected as `VAT`. A file called `vat_rules.rb` is not affected by that and can define `VatRules` just fine. This may be handy if the project has this kind of naming inconsistencies.
0 commit comments