RubyMine 2021.2 Help

Spork DRb

Basics

Running test suits sometimes involves overheads, because every time a test suit is executed, the whole environment (for example, the entire Rails environment for Rails applications) should be reloaded. You can avoid it using the Spork DRb server, which loads the environment only once.

With the Spork DRb server running in the background, you have a choice to execute any testing script using the Spork DRb server, or locally.

Prerequisites

  • Prior to launching Spork DRb server, make sure spork gem, and the corresponding testing gems (rspec-rails, cucumber, cucumber-rails, and so on) are used in your application.

  • spork gem is added to the Gemfile.

To launch Spork DRb server

  1. From the main menu, choose Tools | Run Spork DRb server....

  2. In the Spork DRb Launch Options dialog, select the desired testing framework, and click Run.

    If you are going to use spork for the first time in your project, launch the action with the Perform bootstrap checkbox selected. Thus Spork will patch the testing scripts.

The Spork DRb server starts in a separate tab of the Run tool window.

To run a test script using the Spork DRb server

  1. Make sure that Spork DRb server is launched using RubyMine and is running in the background.

  2. Run a test script, or one of its examples. Note that the option Spork DRb is automatically selected in the corresponding run configuration. If you want to run this test locally, you have to select the option None.

To debug tests, when using Spork DRb, follow these general steps

  1. Make sure the breakpoints are set in the test script you want to debug.

  2. On the main toolbar, click the run/debug configuration selector, and choose Edit Configurations.

  3. In the Run/debug Configurations dialog, create a run/debug configuration for Spork DRb server.

  4. Launch Spork DRb in the debug mode. To do that, with the Spork DRb run/debug configuration selected, click Debug button, or press Shift+F9.

  5. With the Spork DRb server running in the debug mode, run the desired test script.

Managing Spork DRb server

Refer to the description of the Run tool window. In particular, use the following buttons:

  • Stop - stop the Spork DRb server without closing its tab in the Run tool window.

  • Close - close the Spork DRb server tab.

  • Rerun - rerun Spork DRb server in the same tab.

Tips and tricks

  • RubyMine creates a temporary run/debug configuration for Spork DRb server. Later you can change this run/debug configuration as required, save it as permanent, and use it to launch the server.

  • If you are using TeamCity, avoid overhead by adding the following statement into Spork.preload:

    require 'teamcity/spec/runner/formatter/teamcity/formatter'
  • Spork DRb server doesn't work with Ruby 2.0.

  • If both Zeus and Spork DRb servers are running simultaneously, it is Zeus that gets priority.

Spork DRb run/debug configuration

You can specify the following settings for newly created or existing Spork DRb run configuration on the Configuration tab:

Spork script

When the run/debug configuration is created by the Tools | Run SporkDRb server command, this field points to the spork script under the current Ruby interpreter. If you are creating the configuration from scratch, specify the fully qualified path to script.

Test framework

Select the desired testing framework.

Additional arguments

Type additional parameters to be passed to the spork script.

Working directory

Specify the working directory used by the running script.

Environment variables

Specify the list of environment variables as the name-value pairs, separated with semi-colons. Alternatively, click the ellipsis button to create variables and specify their values in the Environment Variables dialog.

Ruby arguments

Specify the command-line arguments to be passed to the Ruby interpreter.

Ruby SDK

Specify the Ruby interpreter used to run a server. You can choose the project default Ruby SDK, or select a different one from the list of configured Ruby SDKs.

Last modified: 27 August 2021