Posted By

noah on 02/08/10


Tagged

testing software rspec ruby tests doc BDD rake failure documents spec failonerror Rakefile


Versions (?)

Howto set up a Rake task to run RSpec spec docs


 / Published in: Ruby
 

URL: http://rspec.rubyforge.org/rspec/1.1.12/classes/Spec/Rake/SpecTask.html

A rake :spec task, is created by default just from including the RSpec rake module.

The way to stop RSpec tasks from failing the entire Rake job when a test barfs, is by setting fail_on_error to false.

  1. require 'spec/rake/spectask'
  2.  
  3. desc 'run specs and generate an HTML specification document'
  4.  
  5. Spec::Rake::SpecTask.new(:spec_doc) do |t |
  6.  
  7. include Helpers::TimeHelper
  8.  
  9. name_for_html_report = 'spec_doc.html'
  10. name_for_log_file = "log/spec_doc.log"
  11.  
  12. t.fail_on_error = false
  13. t.verbose = true
  14. t.spec_files = FileList['examples/**/*.rb']
  15. t.spec_opts = ["-f h:#{name_for_html_report}", "-f o:#{name_for_log_file}", "-f o"]
  16.  
  17. end

Report this snippet  

You need to login to post a comment.