# Create tests

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/ruby/2026.3/llms.txt).

RubyMine provides the ability to create missing tests in various ways. For example, you can:

* create tests from templates

* create a test when [navigating](navigating-between-test-and-test-subject.html) to it from a test subject

* generate tests using Rails generators

Procedure: Mark a directory as a Test Sources Root

Before creating new tests in RubyMine, make sure that the directory dedicated for storing tests is marked as a Test Sources Root. This step helps RubyMine to distinguish the test content in your project and might be necessary for proper functioning of some assistance features, for example, [navigation between a test subject and a particular test file](navigating-between-test-and-test-subject.html).

* In the Project tool window `Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Meta+1` (TextMate), `Ctrl+1` (NetBeans), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS)), right-click the directory where you plan to store your tests and select `Mark Directory As | Test Sources Root` from the context menu.

![Mark a directory as a test source root](https://resources.jetbrains.com/help/img/idea/2026.3/rm_mark_test_source_root.png)

## Create tests from a template

To create a new test from a template, do the following:

Procedure:

1. Do one of the following:

* In the [Project](project-tool-window.html) tool window (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Meta+1` (TextMate), `Ctrl+1` (NetBeans), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS))), select the directory in which you want to create a new file, and then choose `File | New` from the main menu.

* Right-click the directory and select New from the context menu.

* Select the directory and press `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Alt+Insert` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Alt+Insert` (Visual Studio), `⌘ ⌃ N` (Visual Studio (macOS)), `Ctrl+N` (TextMate), `Alt+Insert` (NetBeans), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS)).

2. Select Ruby Test from the list and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (TextMate), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

3. In the New Ruby Test popup, you need to select the [testing framework](testing-frameworks.html) and specify the class name to be tested. For example, do the following to create a new RSpec test:

* Select RSpec.

* Specify the described class name (for example, `User`) and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (TextMate), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

![New Ruby Test popup](https://resources.jetbrains.com/help/img/idea/2026.3/rm_create_tests_new_rspec_popup.png)

4. RubyMine will create a test file with the initial content and open it in the editor. Use this file as a template and add the required code.

![RSpec template editor](https://resources.jetbrains.com/help/img/idea/2026.3/rm_create_tests_rspec_template_example.png)

> **Tip:**
> If necessary, you can modify predefined templates in Settings `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Meta+Comma` (TextMate), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) on the `Editor | File and Code Templates` page. Learn more in [File templates](using-file-and-code-templates.html).

RubyMine provides several ways to generate missing tests for Rails elements (controllers, models, and so on).

Procedure: Create tests using Rails generators

You can use Rails generators supplied with a testing framework to create tests. For example, you can create a model test using the `rspec:model` generator for RSpec or `minitest:model` for Minitest. To do this in RubyMine:

1. Press `Ctrl` (Windows), `Ctrl` (macOS), `Ctrl` (IntelliJ IDEA Classic (macOS)), `Ctrl` (macOS System Shortcuts), `Ctrl` (XWin), `Ctrl` (GNOME), `Ctrl` (KDE), `Ctrl` (Emacs), `Ctrl` (Sublime Text), `Ctrl` (Sublime Text (macOS)), `Ctrl` (Visual Studio), `Ctrl` (Visual Studio (macOS)), `Ctrl` (TextMate), `Ctrl` (NetBeans), `Ctrl` (Eclipse), `Ctrl` (Eclipse (macOS)) twice to invoke the Run Anything popup.

2. In the invoked popup, start typing the required generator name. For example, to create an RSpec model test, start typing rspec:model and then select `rails g rspec:model`. Press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (Visual Studio), `⏎` (Visual Studio (macOS)), `Enter` (TextMate), `Enter` (NetBeans), `Enter` (Eclipse), `⏎` (Eclipse (macOS)).

![Create a new RSpec model test](https://resources.jetbrains.com/help/img/idea/2026.3/rm_rails_generators_new_test.png)

3. Specify the generator arguments. For example, for the User model we pass `user` as an argument. Click OK.

![Add New RSpec:model](https://resources.jetbrains.com/help/img/idea/2026.3/rm_create_tests_add_new_rspec_dialog.png)

Procedure: Create tests alongside Rails elements

Rails allows you to generate tests alongside other applications elements such as controllers, models, and so on. Learn how to create Rails application elements in RubyMine from [Create Rails application elements](creating-rails-application-elements.html).

> **Tip:**
> See [Configuring Generators](https://guides.rubyonrails.org/configuring.html#configuring-generators) to learn how to configure the desired test framework.

