RubyMine 6.3.0 Web Help

After enabling Cucumber support, RubyMine creates common steps definitions in the webrat_steps.rb file; on generating a new feature, a dedicated step definition file is also created. However, if a .feature file refers to a non-existent step, RubyMine's code inspection recognizes and highlights such step, and provides an intention action that helps create missing step definition.

Warning

Step definition files that reside outside the features/step_definitions directory, are not recognized and are highlighted as non-existent. You can specify the path to the required step definitions in the Cucumber run/debug configuration.

To create a missing step definition
  1. While editing the .feature file, type a reference to a step definition. RubyMine highlights step as undefined, and gives detailed information at the tooltip:

    cucumberUndefinedStepInspection

    Tip

    While typing, use code completion Ctrl+SpaceCtrl+SpaceCtrl+SpaceCtrl+SpaceAlt+SlashCtrl+SpaceCtrl+Space or Ctrl+Back SlashCtrl+SpaceCtrl+SpaceControl SpaceControl SpaceControl SpaceControl Space, Alt Escape or Shift Space after keywords. Note that you can narrow down the suggestion list by typing characters contained anywhere within a description. So doing, on top of the suggestion list there will be the variants that contain specified characters as prefixes, followed by the variants with the arbitrary occurrences of characters:

    ruby_cucumberCodeCompletion.png

  2. Press Alt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+Enter, Shift+Alt+J or Ctrl+Shift+MAlt+EnterAlt EnterAlt EnterCommand 1Alt Enter to show the Create Step Definition intention action:

    cucumberCreateStepDefinition

  3. Select the target step definition file from the pop-up list:

    ruby_createUndefinedStep3.png

    You can either select one of the existing step definition files from the suggestion list, or create a new one.

    RubyMine creates a step definition stub in the specified location.

  4. In the selected step definition file that opens in the editor, enter the desired code. Note that the editor turns into the template editing mode and displays the first input field highlighted with the red frame.

    ruby_createUndefinedStep4.png

    Type step definition in this frame and press EnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnterEnter or TabTabTabTabTabTabTabTabTabTabTabTabTab to complete input and pass to the next input field, where you have to enter your source code. After completing input, the caret moves to the end of the suggested step definition, and the editor returns to the regular mode of operation.

Tip

  • You can find usages of a step definition. To do that, place the caret at the desired definition, and press Alt+F7Shift+Alt+7Shift+Alt+7Alt+F7Alt+F7 or Shift+Alt+SShift+Alt+F7Alt+F7Ctrl+GAlt+F7Alt F7Alt F7Shift Command GAlt F7. Refer to the section Finding Usages in Project for details.
  • 3.2+ RubyMine keeps an eye on the uniqueness of the step definitions. Step definitions with the same names are highlighted.

    ruby_cucumber_duplicatedStepDefinition

See Also

Concepts:

Procedures:

Reference:

Web Resources: