The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Using Rcov to measure the test coverage of Rails plugins

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jamie Hill

Posts: 161
Nickname: jamie007
Registered: Nov, 2006

Jamie Hill is Managing Director of SonicIQ Limited in the UK specialising in XHTML, CSS and Rails.
Using Rcov to measure the test coverage of Rails plugins Posted: Aug 24, 2007 12:47 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jamie Hill.
Original Post: Using Rcov to measure the test coverage of Rails plugins
Feed Title: The Lucid
Feed URL: http://feeds.feedburner.com/thelucid
Feed Description: Lightweight ramblings and tips on Ruby and Rails.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jamie Hill
Latest Posts From The Lucid

Advertisement

To view the coverage of your plugins using Rcov, first install the rcov gem with sudo gem install rcov, then copy and paste the following onto the end of the Rakefile inside your plugin directory:

desc 'Measures test coverage using rcov'
task :rcov do
  rm_f "coverage"
  rm_f "coverage.data"
  rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib"
  system("#{rcov} --html #{Dir.glob('test/**/*_test.rb').join(' ')}")
  system("open coverage/index.html") if PLATFORM['darwin']
end

You can now simply run rake rcov from inside your plugin directory which will generate a coverage directory with the results. Open coverage/index.html (if you are on OSX this will open automatically) in a browser to view the results.

Thanks to Mike Clark for his Rcov rake task for Rails which this task is based on.

Read: Using Rcov to measure the test coverage of Rails plugins

Topic: A Call for Apprenticeship Previous Topic   Next Topic Topic: Ruby at SXSW: Railgun Presentation

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use