Rails: how to tell if Spring is loaded

748 Views Asked by At

In recent versions of Rails they've set config.cache_classes = true in config/environments/test.rb. This makes sense to me, as we won't typically be dynamically reloading classes. However, when we run with Spring, it complains that this should be set to false. I would love it if there was a way to thread the needle and accommodate both, something like:

config.cache_classes = !Spring.enabled?

I'm not seeing a way to accomplish this, though. Is there some way to tell if spring is active when the application is booting?

1

There are 1 best solutions below

0
Bart On

Try this:

require 'spring/env'
Spring::Env.new.server_running?
=> true