Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vasfed/routes_coverage
Routes coverage for rails request/integration/capybara tests
https://github.com/vasfed/routes_coverage
coverage coverage-report coverage-status minitest rails rails4 rails5 routes-coverage routing rspec ruby testing
Last synced: 1 day ago
JSON representation
Routes coverage for rails request/integration/capybara tests
- Host: GitHub
- URL: https://github.com/vasfed/routes_coverage
- Owner: Vasfed
- License: mit
- Created: 2017-05-11T17:48:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-09-09T14:46:26.000Z (about 2 years ago)
- Last Synced: 2024-10-29T14:15:21.839Z (10 days ago)
- Topics: coverage, coverage-report, coverage-status, minitest, rails, rails4, rails5, routes-coverage, routing, rspec, ruby, testing
- Language: Ruby
- Size: 370 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# RoutesCoverage
[![Gem Version](https://badge.fury.io/rb/routes_coverage.svg)](https://badge.fury.io/rb/routes_coverage)Sometimes you need to know which routes are covered by your rails test suite.
![Html output example](/assets/html_output_screenshot.png?raw=true "Html Output example")
## Installation
Add this line to your application's Gemfile:
```ruby
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`:
```ruby
RSpec.configure do |config|
config.routes_coverage.perform_report = ENV['ROUTES_COVERAGE'] # only generate report if env var is setconfig.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
```ruby
RoutesCoverage.configure do |config|
config.format = :full_text
# ...
end
```or
```ruby
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](https://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](http://opensource.org/licenses/MIT).