Read more

Disabling Spring when debugging

Dominik Schöler
May 03, 2014Software engineer at makandra GmbH

Spring Show archive.org snapshot is a Rails application preloader. When debugging e.g. the rails gem, you'll be wondering why your raise, puts or debugger debugging statements have no effect. That's because Spring preloads and caches your application once and all consecutive calls to it will not see any changes in your debugged gem.

Howto

Illustration online protection

Rails professionals since 2007

Our laser focus on a single technology has made us a leader in this space. Need help?

  • We build a solid first version of your product
  • We train your development team
  • We rescue your project in trouble
Read more Show archive.org snapshot

Disable spring with export DISABLE_SPRING=1 in your terminal. That will keep Spring at bay in that terminal session.

In Ruby, you can only write environment variables that subprocesses will see Show archive.org snapshot . For tests with a Rails application (i.e., that call rails or rake or other binstubbed commands), this method may help you:

# Use this method to wrap any system calls to the test application
def prepare_environment(&block)
  Bundler.with_clean_env do
    # Spring leads to all kinds of unexpected behavior in tests.
    ENV['DISABLE_SPRING'] = '1'

    block.call
  end
end

Posted by Dominik Schöler to makandra dev (2014-05-03 15:05)