RubyMine 2018.1 Help

Enabling Cucumber Support in Project

Using Cucumber requires creating an infrastructure, which is necessary for further creating and running tests. This infrastructure is created in a slightly different ways for Ruby projects and Rails applications.

Enabling Cucumber support in Ruby projects

In plain Ruby projects, RubyMine provides syntax and error highlighting for feature files and step definitions, and the possibility to create step definitions "from usage". However, you have to produce the necessary folder structure yourself.

Prerequisite

Before you start, make sure that gem 'cucumber' is specified in the Gemfile of your project. If this gem is not yet installed, RubyMine will suggest to download and install it, and all its dependencies

To enable Cucumber support in a Ruby project, follow these general steps

  1. Under the project root directory, create a new directory with the name features (Context menu of the project root - New | Directory).
  2. In this directory, create the required feature files (Context menu of the features directory - New | File - <name>.feature ).
  3. In the feature file, type your scenario. Since there are no step definitions, the steps will be highlighted as unresolved. Create step definitions.

Enabling Cucumber support in Rails applications

Prerequisite

Before you start, make sure that gem 'cucumber-rails' is specified in the Gemfile of your project. If this gem is not yet installed, RubyMine will suggest to download and install it, and all of its dependencies.

When cucumber-rails gem is activated, the cucumber:install generator appears in the list. After executing this generator, RubyMine produces the necessary files and directories:

  • lib/tasks/cucumber.rake
  • features/support/env.rb
  • features/support/paths.rb

To generate Cucumber infrastructure

  1. On the main menu, choose Tools | Run Rails Generators.
  2. In the pop-up window, start typing:
    ruby_enableCucumberSupport.png
  3. Specify the generator options, and click OK. The respective generator script is executed, and displays its output in the console tab of the Run tool window.
Last modified: 1 August 2018

See Also