Search code examples
rubyrspecrake

Is there a way to programmatically count RSpec tests?


Given a Rakefile that executes some RSpec tests by way of a Spec::Rake::SpecTask, how can I programmatically determine the number of tests that passed, failed, and are pending once the task that ran the tests is finished?


Solution

  • SpecTask is just a nice wrapper around sh ruby -S spec ..., so you have no access to the formatter's meta data. You could parse the result, or do the evaluation somewhere else than your Rakefile, or not use SpecTask at all.