RubyMine 2018.1 Help

Creating Test Templates

Introduction

The most basic way to create test templates is to use the regular procedure of creating files in project. This means is available for both plain Ruby projects, and for the Rails applications, and allows creating stub tests for Test::Unit, RSpec and Test-Spec.

For RSpec and Test-Spec RubyMine provides a number of generators. These generators are context-sensitive, and become available depending on the selected location, and on the gems activated for your project. For example, if rspec-rails is activated, the usual generators are hidden, and the list of generators includes only those specific for RSpec.

Creating test templates

To create a test template, follow these general steps

  1. Select the target location in the Project tool window.
  2. Press Alt+Insert.
  3. In the New pop-up menu, select the desired test template:
    ruby generateTest
  4. For an RSpec or Test-Spec test templates, specify the names for the test file, behavior, and "should". For a TestUnit test template, specify the name for the file and test case.
    ruby generateTest rspec

Generating RSpec or Test-Spec test templates

To generate a RSpec or Test-Spec test template, follow these general steps

  1. Press Alt+Insert.
  2. In the Generate pop-up menu, select the desired test template.
  3. Specify the test generator arguments, if any, and 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

Language and Framework-Specific Guidelines: