RubyMine 7.0.1 Web Help

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.

Tip

If you cannot find the necessary generators on the context menus, make sure that all the required gems are installed, and activated for your project. Use the Tools | Ruby on Rails | Reload Generators command on the main menu to refresh the list of available generators.

To create a test template, follow these general steps
  1. Select the target location in the Project tool window.
  2. Press Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertCtrl+N or Alt+InsertAlt+InsertAlt+InsertCtrl+N or Ctrl+Enter⌘ N or Control EnterControl N or Control Enter⌘ N or Control EnterControl N or Control Enter.
  3. In the New pop-up menu, select the desired test template:

    ruby_generateTest.png
    Click thumbnail to view larger image.

  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.png

To generate a RSpec or test-spec test template, follow these general steps
  1. Press Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertCtrl+N or Alt+InsertAlt+InsertAlt+InsertCtrl+N or Ctrl+Enter⌘ N or Control EnterControl N or Control Enter⌘ N or Control EnterControl N or Control Enter.
  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.

Tip

If you create a controller in a Rails application, a Test::Unit test template is generated automatically. If you generate an RSpec Controller, the corresponding RSpec test is generated automatically.

See Also

Procedures:

Language and Framework-Specific Guidelines:

Web Resources: