RubyMine 2018.3 Help

Rails/Spring Support in RubyMine

Spring is a Rails application preloader that speeds up development by keeping your application running in the background. This means you that don’t need to restart a server when you make changes.

In RubyMine, Spring can be used to run Rails generators, tests, and Rake tasks. Make sure that the spring gem is added to the Gemfile and installed to the project’s SDK.

Note that Test::Unit/Shoulda/Minitest tests are run without using Spring by default. To learn how to enable Spring for running tests, see Use Spring for running tests.

Use Spring for running tests

RubyMine lets you specify whether to run tests using the Spring preloader for the specified run/debug configuration. In the example below, we’ll demonstrate how to run all Minitest tests from the test directory in the sample_rails_app project. To do this, you can use the following workflow:

  1. Right-click the test directory in the project view and select Run 'All tests in test: ...'. After performing tests, a corresponding run/debug configuration (All tests in test: sample_rails_app) will be created.

    run configuration for tests
  2. In the navigation bar, expand the list of run/debug configurations and select Edit Configurations.

    Edit run configurations
  3. In the invoked dialog, make sure that the All tests in test: sample_rails_app configuration is selected in the list on the left. Then, set the Use pre-load server option to Spring.

    run/debug configurations dialog

    Click OK. The Spring preloader will be used now to run tests from this run/debug configuration.

Disable Spring

If required, you can disable Spring for a current project. To do this:

  1. From the main menu, select Help | Find Action (Ctrl+Shift+A).

  2. Start typing Spring and disable the Spring pre-loader option.

Stop Spring server

When you launch Rails generators, tests or Rake tasks in RubyMine, it launches a separate instance of the Spring server with a custom SPRING_TMP_PATH environment variable. The value of this variable is equal to {temp_dir}/RMSpring. This means that you need to prepend the Spring server commands with SPRING_TMP_PATH={temp_dir}/RMSpring. For example, if you encounter some issues with Spring on macOS and need to stop it, run the following command:

SPRING_TMP_PATH=${TMPDIR}/RMSpring bin/spring stop
Last modified: 10 January 2019

See Also