Skip to content

Commit 7b95347

Browse files
committed
Update running instructions in README. [doc]
1 parent fc090e9 commit 7b95347

1 file changed

Lines changed: 40 additions & 26 deletions

File tree

README.md

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[Homepage](http://rubyworks.github.com/rubytest) /
44
[User Guide](http://wiki.github.com/rubyworks/rubytest) /
5-
[Development](http://github.com/rubyworks/rubytest) /
6-
[Issues](http://github.com/rubyworks/rubytest/issues)
5+
[Support](http://github.com/rubyworks/rubytest/issues) /
6+
[Development](http://github.com/rubyworks/rubytest)
77

88
[![Build Status](https://secure.travis-ci.org/rubyworks/rubytest.png)](http://travis-ci.org/rubyworks/rubytest)
99
[![Gem Version](https://badge.fury.io/rb/rubytest.png)](http://badge.fury.io/rb/rubytest)
@@ -57,50 +57,64 @@ also be installed in an FHS compliant fashion if necessary.
5757

5858
## Running Tests
5959

60-
There are a few ways to run tests. First, there is the command line tool
61-
e.g.
60+
There are a few ways to run tests.
6261

63-
$ rubytest test/test_*.rb
62+
### Via Runner Scripts
6463

65-
The command line tool takes various options, use `-h/--help` to see them.
64+
Out of the box Ruby Test doesn't provide any special means for doing so,
65+
you simply write you own runner script using the Ruby Test API.
66+
Here is the basic example:
6667

67-
When running tests, you need to be sure to load in your test framework
68-
or your framework's Ruby Test adapter. This is usually done via a helper
69-
script in the test files, but might also be done via command line options,
70-
e.g.
68+
require 'rubytest'
7169

72-
$ rubytest -r lemon -r ae test/test_*.rb
70+
Test.run! do |r|
71+
r.loadpath 'lib'
72+
r.test_files 'test/test_*.rb'
73+
end
74+
75+
Put that in a `test/runner.rb` script and run it with `ruby` or
76+
add `#!/usr/bin/env ruby` at the top and put it in `bin/test`
77+
setting `chmod u+x bin/test`. Either way, you now have your test
78+
runner.
79+
80+
### Via Command-line Tool
7381

74-
Ruby Test supports [dotopts](http://rubyworks.github.com/dotopts) out of the
75-
box, so it easy to setup reusable options. For example, a `.option` file
76-
entry might be:
82+
Probably the easiest way to run tests is via the command line tool available
83+
via the `rubytest-cli` plug-in. You can read more about it on its
84+
[webpage](http://rubyworks.github.com/rubytest-cli), but we will quickly go
85+
over it here.
7786

78-
rubytest
79-
-f progress
80-
-r spectroscope
81-
-r rspecial
82-
spec/spec_*.rb
87+
The basic usage example is:
8388

84-
If you are using a build tool to run your tests, such as Rake or Fire, it is
85-
best to shell out to `rubytest`. This keeps your test environent as prestine
86-
as possible.
89+
$ rubytest -Ilib test/test_*.rb
90+
91+
The command line tool takes various options, most of which correspond directly
92+
to the configuration options of the `Test.run/Test.configure` API. Use
93+
`-h/--help` to see them all.
94+
95+
If you are using a build tool to run your tests, such as Rake or Ergo, shelling
96+
out to `rubytest` is a good way to go as it keeps your test environment as
97+
prestine as possible, e.g.
8798

8899
desc "run tests"
89100
task :test
90101
sh "rubytest"
91102
end
92103

93-
RubyTest comes with a Rake task plugin, but its use is all but deprecated
94-
because it's basically just a glorified rendition of the above.
104+
### Via Rake Task
105+
106+
There is also a Rake plug-in that can be installed called `rubytest-rake`.
107+
Surf over to its [webpage](http://rubyworks.github.com/rubytest-rake) for details.
108+
A basic example in its case, add to one's Rakefile:
95109

96110
require 'rubytest/rake'
97111

98112
Test::Rake::TestTask.new :test do |run|
99113
run.requires << 'lemon'
100-
run.files = 'test/test_*.rb'
114+
run.test_files = 'test/test_*.rb'
101115
end
102116

103-
See the Wiki for more information on the different ways to run tests.
117+
See the Wiki for more detailed information on the different ways to run tests.
104118

105119

106120
## Requirements

0 commit comments

Comments
 (0)