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.
In this section:
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.
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 you to download and install it, and all its dependencies
- Under the project root directory, create a new directory with the name features (Context menu of the project root - ).
- In this directory, create the required feature files (Context menu of the features directory - - <name>.feature ).
- 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
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 you 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:
- On the main menu, choose
If you fail to see the Cucumber generators in the list of available generators, perform Reload Rails generators command.
- In the pop-up window, start typing:
- 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.