Using RSpec in Ruby Projects
This feature is only supported in the Ultimate edition.
The following is only valid when Ruby Plugin is installed and enabled!
Though IntelliJ IDEA provides RSpec test template by default, the complete RSpec support only becomes available, when
rspec gem is attached to your Ruby project. IntelliJ IDEA's RSpec support, in particular, includes:
- The possibility to run and debug individual examples.
- Use RSpec-specific code completion:
To enable RSpec support in a Ruby project, perform these general steps:
- Create a directory, for example,
test, that will be used for testing purposes.
- Mark the new directory as a test source.
- Make sure that
rspecgem is added to your project.
- In the directory you've created for testing, generate test templates.
- Run or debug your spec.
If you are using the bundler, make sure that in the RSpec run/debug configuration the checkbox 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 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 . 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 .