diff --git a/lib/spring/application.rb b/lib/spring/application.rb index 6fdbbb3a..8a2a7283 100644 --- a/lib/spring/application.rb +++ b/lib/spring/application.rb @@ -129,6 +129,8 @@ def preload watcher.add secrets_path end end + + ActiveSupport.run_load_hooks(:spring_booted, self) end def eager_preload diff --git a/test/support/acceptance_test.rb b/test/support/acceptance_test.rb index af2acc31..c41f8a1a 100644 --- a/test/support/acceptance_test.rb +++ b/test/support/acceptance_test.rb @@ -715,6 +715,16 @@ def exec_name test "rails db:system:change" do assert_success "bin/rails db:system:change --to=sqlite3" end + + test "spring_booted load hook is called when booting the application" do + File.write(app.path("config/initializers/spring_booted.rb"), <<~RUBY) + ActiveSupport.on_load(:spring_booted) do + raise "Argh!" + end + RUBY + + assert_failure "bin/rails runner ''", stderr: "Argh!" + end end end end