Skip to content

RSpec

Terminal window
bundle add selective-ruby-rspec
bundle exec selective rspec

selective rspec is a drop-in replacement for rspec. Every RSpec flag, file argument and tag filter is forwarded, so whatever your CI passed to rspec before can be passed unchanged:

Terminal window
bundle exec selective rspec spec/models spec/services --tag ~slow

What changes is where the examples come from. Instead of running everything it can see, the runner reports the examples it found to Selective and then runs whichever ones Selective hands it, in the order Selective chooses. On a node with nothing left to do, the command exits once the queue is empty.

Two flags belong to Selective rather than RSpec:

FlagEffect
--debugVerbose output about the connection and the work the node is given. Ask for this in bug reports.
--logWrite the runner’s log to a file.

The gem ships a native transport binary for x86_64-linux, aarch64-linux, x86_64-darwin and arm64-darwin. If CI reports Unable to find executable for <platform>, add the platform to your lockfile:

Terminal window
bundle lock --add-platform x86_64-linux

Installing the gem builds selective_tracer, a small native extension used to record which files each example executes. That needs make and a C compiler. If the build fails, installation still succeeds and the runner works normally; the only thing it can’t do is record a test map. See Test selection.

Your configured RSpec formatters run as usual on each node, so per-node JUnit or JSON output keeps working. The combined view across nodes is the Selective dashboard.