print coverage for 1 test/spec file
Install
gem install simplecov-single_file_reporter
Usage
Simple setup
Print coverage percent when you run a single file
require "simplecov/single_file_reporter"
SimpleCov.start
SimpleCov::SingleFileReporter.print
ruby test/a_test.rb
1 tests, 1 assertions
lib/a.rb coverage: 80.0
Customizing file-finding rules
SingleFileReporter needs to find the file that is tested.
test/test_xxx.rb -> lib/xxx.rb or app/xxx.rb
If it's something common, make a pull request.
If your app has special rules you can add them:
class MyReporter < SimpleCov::SingleFileReporter
remove :file_under_test
def self.file_under_test(test_file)
super(test_file) || test_file.split("test/").last.sub("foo", "bar").sub("_test.rb", ".rb")
end
end
SimpleCov.start
MyReporter.print
Authors
Michael Grosser
michael@grosser.it
License: MIT