The target of this formatter is to cheat on metric_fu so it’s possible to use simplecov instead rcov.
gem install simplecov-rcov-text
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.
require 'simplecov' require 'simplecov-rcov-text' SimpleCov.formatter = SimpleCov::Formatter::RcovTextFormatter
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
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!
metric_fu shift the first line class SomeClass def method_1 1+1 end def method_2 ( value ) !! value * value end end
bundle rake