RubyMine 6.3.0 Web Help

Using RSpec in Rails application requires rspec-rails gem to be activated in your project. So doing the dependent rspec gem is attached to the project automatically. When the rspec-rails gem is activated, the corresponding generator rspec:install appears in the list of available generators.

5.0+

RubyMine supports rspec-rails gem version 2.12.0 and higher.

When RSpec support is enabled in a Rails application, RubyMine provides:

Depending on your particular version of Rails, different workflows are possible. If you are using Rails 3.0 and higher, it is recommended to use the bundler and specify rspec-rails gem in the Gemfile. Thus, RubyMine suggests the following workflow:

To use RSpec, follow these general steps
  1. Make sure that the required gems are installed.
  2. In the Gemfile, add the line
    gem 'rspec-rails'
  3. Generate the RSpec testing infrastructure. To do that, press Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertCtrl+N or Alt+InsertAlt+InsertAlt+InsertCtrl+N or Ctrl+EnterCommand N or Control EnterControl N or Control EnterCommand N or Control EnterControl N or Control Enter, choose Run Rails Generator on the pop-up menu, start typing the rspec generator name, and choose rspec:install from the list:

    ruby_rspec_install

    In the Setup RSpec Support dialog box, specify the generator options. The respective script is executed, and displays its output in the console tab of the Run tool window.

  4. Generate the test templates same way as the other Rails application elements.
  5. Run or debug your spec.

    If you are using the bundler, make sure that in the RSpec run/debug configuration the check box Run the script in context of the bundle is selected.
    Note that you can execute all tests in a folder, specific test script, or individual examples in a script.

    • To execute all tests in a folder, in the Project tool window right-click the folder that contains specs, and choose Run: All specs in <folder name> on the context menu.
    • To execute a test script, right-click the spec in the Project tool window, or open this spec in the editor and right-click somewhere outside individual examples. Then choose Run <spec name>. on the context menu.
    • To execute an individual example, open the desired spec in the editor, right-click the example to be executed, and choose Run <Spec name><example name>

See Also

Procedures:

Web Resources: