Originally I and my colleague prepared this post for Syndicode blog. Then I decided to share it to my fav community.
When you hear the word Ruby, what is the first thing that comes to your mind? Some of its advantages? Or the list of projects that were developed using Ruby? I think of Ruby as of something you can really have fun working with. And that is proven my many gems that simplify the dev's life. The next one is here for you today. Undercover is a new Ruby gem for code coverage that its creator calls 'RuboCop but for code coverage'.
Undercover inspects files in and warns on methods, classes, and blocks that we need to test coverage.
That's what you need to do first:
- Add this line to your application's Gemfile:
- Then execute:
- Or install it as:
$ gem install undercover
To make your specs or tests compatible with
undercover by providing an LCOV report, please add
simplecov-lcov to your test setup.
The aim of the author was to create a tool to help others ensure that tests are written for all the recent code changes. This works for any ruby project, but especially big codebases that lack testing.
The goal was to provide automated warnings, that are:
- relevant, so scoped to the actual code changes
- timely, so we don't write tests long after the implementation
- actionable, so we can fix them before the code is committed
For more background, please check Undercover GitHub page.
Don't hesitate to check my latest Rails digest with the most interesting and promising Ruby gems!