Skip to content

Commit d4d16e2

Browse files
committed
Document testing in the autoloading guide
1 parent e74012c commit d4d16e2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

guides/source/autoloading_and_reloading_constants.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,27 @@ However, if an engine supports Rails 6 or Rails 6.1 and does not control its par
456456

457457
3. In `classic` mode, a file `app/model/concerns/foo.rb` is allowed to define both `Foo` and `Concerns::Foo`. In `zeitwerk` mode, there's only one option: it has to define `Foo`. In order to be compatible, define `Foo`.
458458

459+
Testing
460+
-------
461+
462+
### Manual Testing
463+
464+
The task `zeitwerk:check` checks if the project tree follows the expected naming conventions and it is handy for manual checks. For example, if you're migrating from `classic` to `zeitwerk` mode, or if you're fixing something:
465+
466+
```ruby
467+
% bin/rails zeitwerk:check
468+
Hold on, I am eager loading the application.
469+
All is good!
470+
```
471+
472+
There can be additional output depending on the application configuration, but the last "All is good!" is what you are looking for.
473+
474+
### Automated Testing
475+
476+
It is a good practice to verify in the test suite that the project eager loads correctly.
477+
478+
That covers Zeitwerk naming compliance and other possible error conditions. Please check the [section about testing eager loading](testing.html#testing-eager-loading) in the [_Testing Rails Applications_](testing.html) guide.
479+
459480
Troubleshooting
460481
---------------
461482

0 commit comments

Comments
 (0)