Mastering RubyMine’s Built‑In RSpec Support: Run, Debug, and Configure Tests
Learn how RubyMine’s integrated RSpec support simplifies test execution, debugging, and configuration. Follow a step‑by‑step example with a Calculator class, discover run‑config options, and weigh the trade‑offs for large test suites.
06 Apr 2026, 23:07 UTC

Problem: Test Chaos in Ruby Projects
When a Ruby project grows, the sheer number of spec files can make it hard to know which tests to run, how to isolate failures, and where a bug originates. Running rspec from the command line is fine, but the IDE can add a layer of clarity by presenting a dedicated test runner, configurable run profiles, and an in‑IDE debugger that stops inside the very line that fails.
Thesis: RubyMine’s RSpec Feature Is a One‑Stop Test Hub
RubyMine ships with RSpec support enabled out of the box. The IDE automatically detects spec files (matching *_spec.rb), presents a toolbar for quick actions, and lets you create fine‑grained run configurations that specify Ruby SDKs, environment variables, and test filters. When a test fails, the debugger attaches seamlessly, allowing you to step through the code, inspect variables, and understand the failure in context.
1. Detecting and Running Specs
After adding the rspec gem to your Gemfile and running bundle install, RubyMine will automatically create an RSpec tab in the Project view. Each spec file appears under this tab, and a green “Run RSpec” icon appears next to the file name.
- Open RubyMine and load your project.
- Ensure
rspecis inGemfile:group :test do gem "rspec" end - Run
bundle installin the terminal. - In the Project view, locate
spec/calculator_spec.rbunder the RSpec node. - Click the green icon – the spec runs in the Run window, displaying a pass/fail summary.
To verify the integration, look for the RSpec Toolbar at the top of the Run window. It contains buttons for “Run All”, “Run Current”, and “Debug Current”.
2. Configuring Run Settings
While the default run configuration is handy for quick checks, you often need isolated contexts:
- Environment Variables – e.g.,
RAILS_ENV=testorDEBUG=true. - Specifying a Ruby SDK – useful if the project supports multiple Ruby versions.
- Running a single folder or file – great for CI or focused debugging.
- Using RSpec tags to filter tests (e.g.,
--tag focus).
To create a custom configuration:
- Open the Run/Debug Configurations dialog via the toolbar or
Run > Edit Configurations. - Click the
+icon and select RSpec. - Give it a descriptive name, e.g., Calculator Spec (Debug).
- Set the Ruby SDK from the dropdown.
- In the Environment variables field, add
DEBUG=true(separated by semicolons on Windows, colons on macOS/Linux). - Under Run options, you can add tags:
--tag focus. - Apply and close.
Now, when you run or debug this configuration, the IDE will launch RSpec with the exact options you specified.
3. Debugging with Breakpoints
The real power of RubyMine’s RSpec integration shows up when a test fails or you want to step through the code. Here’s a concrete walkthrough using a simple Calculator class.
# lib/calculator.rb
class Calculator
def add(a, b)
a + b
end
end
# spec/calculator_spec.rb
require_relative "../lib/calculator"
RSpec.describe Calculator do
it "adds two numbers" do
calc = Calculator.new
expect(calc.add(2, 3)).to eq(5)
end
end
Steps:
- Open
calculator.rband set a breakpoint on theaddmethod line. - Open
calculator_spec.rband click the green Debug RSpec icon (or run the custom configuration in debug mode). - The debugger stops at the breakpoint. The Debugger panel shows the call stack, local variables (
a,b,calc), and the current line. - Use the step‑into (
F7) and step‑over (F8) buttons to navigate the test flow. - When the test finishes, the Run window displays the result; if it fails, you can quickly inspect the state that caused the failure.
Result verification: In the Run window you should see a green checkmark for the test. If you hit the breakpoint, the debugger will pause, and the Variables pane will list a=2, b=3. This confirms the test executed as expected.
4. Trade‑offs and Limitations
While the built‑in RSpec support is powerful, it has a few caveats:
- Startup Overhead – RubyMine launches an RSpec process for each run. In very large suites (hundreds of files), this can noticeably slow IDE startup.
- Gem Dependency – The feature relies on the
rspecgem being present. If the gem is missing or the version is incompatible, the IDE may not detect spec files. - RubyMine Version – Integrated debugging requires RubyMine 2019.2 or newer. Older releases lack this capability.
Mitigation strategies:
- Disable the automatic test runner in
Settings > Build, Execution, Deployment > RSpecif startup becomes an issue. - Use the command‑line
bundle exec rspecfor heavy suites and only enable the IDE debugger for focused tests. - Keep the
Gemfileup to date and runbundle installafter addingrspec.
5. Actionable Takeaway
RubyMine’s RSpec integration turns the IDE into a full‑featured test harness:
- Detect spec files automatically via naming conventions.
- Create granular run configurations with SDK, env vars, and tags.
- Debug test runs with breakpoints, step‑through, and variable inspection.
- Monitor results in the dedicated Run window.
Next steps for you:
- Ensure
rspecis in yourGemfileand runbundle install. - Open the RSpec Toolbar and try a quick run.
- Create a custom configuration for a focused test file.
- Set a breakpoint in the production code and debug the spec.
- If you notice performance hiccups, consider disabling the auto‑runner or using a dedicated command‑line run for large suites.
By following these steps, you’ll reduce the friction of running, isolating, and diagnosing Ruby tests, and you’ll keep your workflow efficient even as your test suite grows.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.