Simplecov Rcov Formatter Text
The target of this formatter is to cheat on metric_fu so it’s possible to use simplecov instead rcov.
Install
gem install simplecov-rcov-text
Usage
Add the gem to the Gemfile preferably in the group test:
gem 'simplecov', :require => false
gem 'simplecov-rcov-text', :require => false
Create a .metrics file in the root of project with the code:
MetricFu::Configuration.run do |config|
config.rcov[:external] = 'coverage/rcov/rcov.txt'
end
And follow the instructions of Simplecov and metric_fu or metrical.
Simplest way
require 'simplecov'
require 'simplecov-rcov-text'
SimpleCov.formatter = SimpleCov::Formatter::RcovTextFormatter
Using with HTML Format
require 'simplecov'
require 'simplecov-rcov-text'
class SimpleCov::Formatter::MergedFormatter
def format(result)
SimpleCov::Formatter::HTMLFormatter.new.format(result)
SimpleCov::Formatter::RcovTextFormatter.new.format(result)
end
end
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
Running metric_fu/metrical
Be sure that you configured simplecov and simplecov-rcov-text.
Run your test framework, example:
rspec spec
After that you can run the metric_fu/metrical command.
Don’t forget to configure .metrics file!
Example of generated file
metric_fu shift the first line
class SomeClass
def method_1
1+1
end
def method_2 ( value )
!! value * value
end
end
Running tests
bundle
rake