Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nebulab/reverse_coverage
A tool to find the test examples which cover a specific line (or set of lines) of a Ruby project
https://github.com/nebulab/reverse_coverage
rspec ruby
Last synced: 3 days ago
JSON representation
A tool to find the test examples which cover a specific line (or set of lines) of a Ruby project
- Host: GitHub
- URL: https://github.com/nebulab/reverse_coverage
- Owner: nebulab
- License: mit
- Created: 2019-08-09T13:37:27.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-04T09:14:48.000Z (over 1 year ago)
- Last Synced: 2025-01-06T16:43:20.600Z (19 days ago)
- Topics: rspec, ruby
- Language: JavaScript
- Homepage:
- Size: 351 KB
- Stars: 77
- Watchers: 7
- Forks: 7
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Gem Version](https://badge.fury.io/rb/reverse_coverage.svg)](https://badge.fury.io/rb/reverse_coverage)
# ReverseCoverage
The goal of this component is to find what RSpec examples "cover" one or more lines of code of a Ruby project.
This is useful for example when you override methods of a parent product and you want to check what/how the specs treat the original lines.
Blog post introduction: [https://nebulab.it/blog/reverse-coverage/](https://nebulab.it/blog/reverse-coverage/)
## Installation
Add `gem 'reverse_coverage'` to your application's Gemfile and execute `bundle`.
Put the following code under you specs configuration:
```ruby
require 'reverse_coverage'RSpec.configure do |config|
config.before(:suite) do
ReverseCoverage::Main.start
endconfig.around do |e|
e.run
ReverseCoverage::Main.add(e)
endconfig.after(:suite) do
ReverseCoverage::Main.save_results
coverage_matrix = ReverseCoverage::Main.coverage_matrix
ReverseCoverage::Formatters::HTML::Formatter.new.format(coverage_matrix)
end
end
```## Usage
Run your specs, inspect the `'tmp/reverse_coverage.yml'` file or open `'tmp/index.html'` file.
To configure the base URL used to open a specific spec edit the generated `'tmp/settings.js'` file. Without changes, the default behavior is to open files locally.
## Options
- `file_filter`: allows to set a lambda to filter what files belongs to the project. Example (to add before `ReverseCoverage::Main.start` line): `ReverseCoverage::Main.config[:file_filter] = ->(file_path) { file_path.include? 'faked_project' }`
## Testing
Execute `bundle exec rspec` on the component root path, specs are based on an internal fake project.
## HTML output screenshot
Here it is a screenshot of the generated HTML interface:
![Reverse Coverage screenshot](extra/screenshot.jpg)
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/nebulab/reverse_coverage. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## License
ReverseCoverage is copyright © 2019 [Nebulab](http://nebulab.it/). It is free software, and may be redistributed under the terms specified in the [license](LICENSE.txt).
## About
![Nebulab](http://nebulab.it/assets/images/public/logo.svg)
ReverseCoverage is funded and maintained by the [Nebulab](http://nebulab.it/) team.
We firmly believe in the power of open-source. [Contact us](http://nebulab.it/contact-us/) if you like our work and you need help with your project design or development.