Skip to content

Commit 5fc4957

Browse files
transclaude
andcommitted
Expand CLI documentation in README
Add configuration file examples and profile usage from the former rubytest-cli project, which has been merged into rubytest. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6971bec commit 5fc4957

File tree

1 file changed

+41
-6
lines changed

1 file changed

+41
-6
lines changed

README.md

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,48 @@ The easiest way to run tests is via the command line tool:
5757

5858
$ rubytest -Ilib test/test_*.rb
5959

60-
The command line tool takes various options, most of which correspond directly
61-
to the configuration options of the `Test.run/Test.configure` API. Use
62-
`-h/--help` to see them all.
60+
This would add `lib` to Ruby's `$LOAD_PATH` and then load all the
61+
test files matching the glob. When running tests, be sure to load your
62+
test framework or its adapter, e.g.
6363

64-
If you are using a build tool to run your tests, such as Rake, shelling
65-
out to `rubytest` is a good way to go as it keeps your test environment as
66-
pristine as possible, e.g.
64+
$ rubytest -r lemon -r ae test/test_*.rb
65+
66+
Use `-h/--help` to see all available options.
67+
68+
#### Configuration File
69+
70+
To avoid repeating options, add an `etc/test.rb` file to your project
71+
with `Test.run` (or `Test.configure`) entries:
72+
73+
```ruby
74+
Test.run do |r|
75+
r.loadpath 'lib'
76+
r.test_files << 'test/*_test.rb'
77+
end
78+
79+
Test.run 'coverage' do |r|
80+
r.loadpath 'lib'
81+
r.test_files << 'test/*_test.rb'
82+
r.before do
83+
require 'simplecov'
84+
SimpleCov.start do |s|
85+
s.filter 'test/'
86+
s.coverage_dir 'log/coverage'
87+
end
88+
end
89+
end
90+
```
91+
92+
Now `rubytest` will use the first configuration by default. To use a
93+
named profile, use the `-p/--profile` option:
94+
95+
$ rubytest -p coverage
96+
97+
The configuration file can also be at `config/test.rb`, `Testfile`,
98+
or `.test` (with optional `.rb` extension).
99+
100+
If you are using Rake, shelling out to `rubytest` keeps your test
101+
environment pristine:
67102

68103
desc "run tests"
69104
task :test

0 commit comments

Comments
 (0)