This new StatRunner is very simple and the only customization is that it prints the result line wrapped in a box.
Now imagine that this StatRunner is defined in the test/stat_runner.rb file. The rake task in the rakefile would look like:
123456789
1 2 3 4 5 6 7 8 9
<span class='line'># http://rake.rubyforge.org/classes/Rake/TestTask.html
</span><span class='line'>require 'rake/testtask'
</span><span class='line'>Rake::TestTask.new(:test) do |test|
</span><span class='line'> test.libs << 'lib' << 'test' # test dir is in, so we can do -rstat_runner
</span><span class='line'> test.ruby_opts=['-rstat_runner'] # require stat_runner.rb in spawned ruby process
</span><span class='line'> test.pattern = 'test/**/test_*.rb'
</span><span class='line'> test.verbose = true
</span><span class='line'> test.options="--runner=stat" #force to use the new runner called stat (has to be in RUNNERS)
</span><span class='line'>end</span>
That’s it. Now if you run your rakefile you’ll get
Started
========================================================================
| Finished in 0.000103 seconds. |
========================================================================
1 tests, 1 assertions, 0 failures, 0 errors