rspec_test
Ruby Specification (RSpec) tests run through Struo.
Start Here#
Struo resolves the Ruby interpreter and the Ruby Specification runner as separate tools. Each may be a name on the executable search path, an absolute path, or a workspace-relative path. A common direct installation is:
gem install rspecRetrieve the runnable starter when you want a complete declaration and sample specifications:
struo query example rspec_test rspec-test-minimal --format jsonCopy the declaration below into struo.toml, adjust srcs and the Ruby
environment for the project, then establish discovery and run the file
batches:
struo test tests --format json
struo query test-manifest tests --format json
struo test tests --jobs 4 --format jsonThe first command runs the complete target. Later runs can use the resulting manifest for automatic batching and exact selection. See Testing and Scheduling for affected plans, case-level batching, and exact unit commands.
Description#
rspec_test invokes the selected Ruby Specification command with its
structured formatter, converts examples into stable target-qualified
identifiers, and writes normalized Struo results. Exact execution passes the
native example identifier back to the runner.
Struo selects the formatter by its fully qualified RSpec class name, so its
reporting option does not look like an application's --format json option
to tests that inspect command-line arguments.
The target kind declares Ruby and Ruby Specification as tool requirements. The runner does not need to be loadable by an unrelated system Ruby installation.
Automatic batching uses one batch per specification file by default. Set
batching to case for individual examples, or target for one target batch.
A complete discovery run is required before smaller batches are planned.
Attributes#
| Attribute | Type | Required | Default | Description |
|---|---|---|---|---|
ruby | string | no | ruby | Ruby interpreter name, absolute path, or workspace-relative path |
runner | string | no | rspec | Ruby Specification runner name, absolute path, or workspace-relative path |
config | list<string> | no | Gemfile, Gemfile.lock | Dependency and runner configuration inputs |
data | list<string> | no | [] | Runtime data and support inputs |
args | list<string> | no | [] | Additional runner arguments |
coverage_per_test | bool | no | false | Measure each example independently with Ruby Coverage |
coverage_sources | list<string> | no | [] | Product Ruby source globs to instrument |
env | map<string, string> | no | {} | Explicit test environment variables |
env_inherit | list<string> | no | [] | Host environment variables inherited by name |
batching | string | no | file | Automatic granularity: file, case, or target |
labels | list<string> | no | [] | Labels exposed through test discovery |
timeout_ms | int | no | empty | Optional timeout in milliseconds |
Dependency Edges#
deps names targets whose changes should select this test target.
Providers and Capabilities#
The target emits struo_test_info and exposes test with the default,
test_results, and logs output groups.
test-discovery emits the current example identifiers through native dry-run
collection. Failed collection cannot publish an inventory. Opt-in
coverage_per_test uses the current inventory and measures one exact example
per process, without reusing cached observations. Declare product Ruby paths
in coverage_sources. Ruby Coverage must support line_stub so unloaded
sources remain in the zero-hit instrumented universe. Child processes,
skipped examples and failed runs cannot establish complete checkpoints.
Example#
[[target]]
name = "tests"
kind = "rspec_test"
srcs = ["spec/**/*_spec.rb"]
[target.attrs]
env_inherit = ["GEM_HOME", "GEM_PATH"]List helper files and other runtime inputs in data when they are outside the
source patterns.