The Wire · Showcase
SPRING HOOKS INTO RAILS PRELOADING, CUTTING TEST STARTUP TIME
By RepoJournal · Filed · About Rails
Spring just shipped a game-changer for test suites: a new after_environment_load hook that lets you preload expensive test infrastructure once instead of on every fork.
The Spring team merged support for Spring.after_environment_load [1], a hook that runs after Rails loads but before the server forks test workers. This means expensive operations—fixture caches, datastore connections, test helpers—load once into the parent process and inherit via copy-on-write to every forked worker, slashing per-test overhead. Shopify drove this work [2], and it ships with full acceptance and unit test coverage [3] [4]. On the Rails website front, the team is building out This Week in Rails [5], a new recurring feature to keep you closer to what's shipping. The devcontainer setup also got locked down [6] for consistency across contributor environments.
One email a day. Unsubscribe in one click.
Keep up with Rails in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.
One email a day. Unsubscribe in one click. Read a past issue →
Action items
- → Pull Spring when it lands—this is a free performance win for any test suite with heavy setup costs rails/spring [plan]
- → Refactor your test setup to use after_environment_load for expensive preloads rails/spring [plan]
References
- [1] Add Spring.after_environment_load hook for post-Rails preloading
- [2] Merge pull request #754 from Shopify/add-after-environment-load-hook
- [3] Add acceptance test for after_environment_load callback
- [4] Add unit tests for Spring.after_environment_load
- [5] Add This Week in Rails
- [6] Add devcontainer lock