Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

routes_coverage

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

routes_coverage

  • 0.7.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

RoutesCoverage

Gem Version

Sometimes you need to know which routes are covered by your rails test suite.

Html output example

Installation

Add this line to your application's Gemfile:

gem 'routes_coverage', group: :test

And then execute:

$ bundle

Or install it yourself as:

$ gem install routes_coverage

Usage

Install the gem and run your tests, then open generated report file coverage/routes.html.

Configuration

By default html report with no groupping is generated. If you need more funtionality - options in RoutesCoverage.settings or rspec's config.routes_coverage:

RSpec.configure do |config|
  config.routes_coverage.perform_report = ENV['ROUTES_COVERAGE'] # only generate report if env var is set

  config.routes_coverage.exclude_put_fallbacks = true # exclude non-hit PUT-requests where a matching PATCH exists
  config.routes_coverage.include_from_controller_tests = true # include results from controller tests
  config.routes_coverage.exclude_patterns << %r{PATCH /reqs}   # excludes all requests matching regex
  config.routes_coverage.exclude_namespaces << 'somenamespace' # excludes /somenamespace/*

  config.routes_coverage.groups["Some Route group title"] = %r{^/somespace/}
  config.routes_coverage.groups["Subdomain"] = { constraints: { subdomain: 'some_subdomain' }, path: '/' }
  config.routes_coverage.groups["Admin"] = Regexp.union([
    %r{^/admin/},
    %r{^/secret_place/},
  ])

  config.routes_coverage.format = :html # html is default, others are :full_text and :summary_text, or your custom formatter class

  config.routes_coverage.minimum_coverage = 80 # %, your coverage goal
  config.routes_coverage.round_precision = 0   # just round to whole percents
end

Excluded routes do not show in pending, but are shown if they're hit.

If rspec is not your choice - use

RoutesCoverage.configure do |config|
  config.format = :full_text
  # ...
end

or

RoutesCoverage.settings.format = :full_text

Note that coverage from include_from_controller_tests (disabled by default) is not a true routes coverage. Rounting is not tested in controller tests (which are deprecated in Rails 5), but sometimes you may already have a lot of controller tests and an intent to improve green-path/business level coverage

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

To run tests against different rails versions use appraisal rake

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Vasfed/routes_coverage.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 24 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc