Rake Tasks
RSpec comes with a Rake task for executing specs.
See Spec::Rake::SpecTask API for details.
Rake task example
This is a snippet from RSpec’s own Rakefile. It creates a task to run the examples.
require 'rake' require 'spec/rake/spectask' desc "Run all examples" Spec::Rake::SpecTask.new('examples') do |t| t.spec_files = FileList['examples/**/*.rb'] end
It can be invoked from the command line with:
rake examples
Also see the RCov page for info about how to generate a coverage report.
Generate HTML report
require 'rake' require 'spec/rake/spectask' desc "Generate HTML report for failing examples" Spec::Rake::SpecTask.new('failing_examples_with_html') do |t| t.spec_files = FileList['failing_examples/**/*.rb'] t.spec_opts = ["--format", "html:doc/reports/tools/failing_examples.html", "--diff"] t.fail_on_error = false end
This will write a HTML file that looks like this.