Giter VIP home page Giter VIP logo

reverse_coverage's Introduction

Gem Version

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/

Installation

Add gem 'reverse_coverage' to your application's Gemfile and execute bundle.

Put the following code under you specs configuration:

require 'reverse_coverage'

RSpec.configure do |config|
  config.before(:suite) do
    ReverseCoverage::Main.start
  end

  config.around do |e|
    e.run
    ReverseCoverage::Main.add(e)
  end

  config.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

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 code of conduct.

License

ReverseCoverage is copyright © 2019 Nebulab. It is free software, and may be redistributed under the terms specified in the license.

About

Nebulab

ReverseCoverage is funded and maintained by the Nebulab team.

We firmly believe in the power of open-source. Contact us if you like our work and you need help with your project design or development.

reverse_coverage's People

Contributors

danielepalombo avatar blocknotes avatar jmgarnier avatar

Stargazers

Janosch Müller avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.