Running RSpec with optional SimpleCov
I wanted to use SimpleCov within one of my latest Rails applications, but I wanted it to be a seperate rake task instead of running all the time.
First add SimpleCov to your Gemfile.
gem 'simplecov', '~> 0.4.2'
Add a new task to your Rakefile, this is an example with RSpec.
desc "Run tests with SimpleCov"
Spec::Rake::SpecTask.new('coverage') do |t|
ENV['COVERAGE'] = "true"
end
Then add the following to the top of your spec_helper.rb file.
if ENV['COVERAGE']
require 'simplecov'
SimpleCov.start
# For rails applications use
# SimpleCov.start 'rails'
end
Published on Monday, 25 July 2011
All posts
- How to reach your host machine from VirtualBox
- Running RSpec with optional SimpleCov
- Handy Rails string functions
- Sexy documenting with Docco & Rocco
- Playing with CoffeeScript
- Time to learn: Behaviour Driven Development
- Getting up and running with Cucumber and Test::Unit
- My HTML Toolkits
- First networking meeting
- Using php.activerecord with Zend Framework
- How to create a Zend Controller Plugin
- JavaScript CDATA