Skip to content

SimpleCov formatter to generate a simple index.html Rcov style

Notifications You must be signed in to change notification settings

moneyforwardvietnam/simplecov-rcov

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleCov Rcov Formatter gem

SimpleCov Rcov logo

Is a Rcov style formatter for the ruby 1.9+ coverage gem: SimpleCov.

The target of this formatter is to cheat on Hudson so I can use the Ruby metrics plugin with SimpleCov.

So if you are looking some kind of workaround to integrate SimpleCov with your Hudson + Ruby metrics plugin this is a beginning.

Install

$ [sudo] gem install simplecov-rcov

Usage

require 'simplecov-rcov'
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter

Or if you want to share this formatter with another formatter like HTML formatter you can add both:

require 'simplecov'
require 'simplecov-rcov'
class SimpleCov::Formatter::MergedFormatter
  def format(result)
     SimpleCov::Formatter::HTMLFormatter.new.format(result)
     SimpleCov::Formatter::RcovFormatter.new.format(result)
  end
end
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter

You can also add a flag support so if you don't run the tests activating the COVERAGE environment variable to on the coverage report won't be used:

if( ENV['COVERAGE'] == 'on' )
  require 'simplecov'
  require 'simplecov-rcov'
  class SimpleCov::Formatter::MergedFormatter
    def format(result)
       SimpleCov::Formatter::HTMLFormatter.new.format(result)
       SimpleCov::Formatter::RcovFormatter.new.format(result)
    end
  end
  SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
  SimpleCov.start 'rails' do
    add_filter "/vendor/"
  end
end

Run it using this:

$ COVERAGE=on rake test

ISSUES

To add the gem to the Gemfile try to do it this way:

gem 'simplecov', :require => false
gem 'simplecov-rcov', :require => false

And require the gems just before use the SimpleCov constant, like in the examples above.

If not could be Uninitialized constant SimpleCov issues.

Credits

About

SimpleCov formatter to generate a simple index.html Rcov style

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 42.7%
  • HTML 31.8%
  • CSS 20.5%
  • JavaScript 5.0%