{"id":15240475,"url":"https://github.com/ohbarye/route_mechanic","last_synced_at":"2025-10-14T02:08:42.597Z","repository":{"id":45539524,"uuid":"293235286","full_name":"ohbarye/route_mechanic","owner":"ohbarye","description":"RouteMechanic detects broken routes with ease :train:","archived":false,"fork":false,"pushed_at":"2024-05-21T15:10:16.000Z","size":65,"stargazers_count":11,"open_issues_count":5,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-08T04:54:54.515Z","etag":null,"topics":["automation","minitest","rails","rspec","ruby","testing"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/route_mechanic","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ohbarye.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-06T08:33:11.000Z","updated_at":"2024-05-21T15:10:20.000Z","dependencies_parsed_at":"2025-02-17T10:41:39.032Z","dependency_job_id":null,"html_url":"https://github.com/ohbarye/route_mechanic","commit_stats":null,"previous_names":["ohbarye/route_machanic"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/ohbarye/route_mechanic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohbarye%2Froute_mechanic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohbarye%2Froute_mechanic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohbarye%2Froute_mechanic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohbarye%2Froute_mechanic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ohbarye","download_url":"https://codeload.github.com/ohbarye/route_mechanic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohbarye%2Froute_mechanic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016933,"owners_count":26085908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","minitest","rails","rspec","ruby","testing"],"created_at":"2024-09-29T11:05:09.686Z","updated_at":"2025-10-14T02:08:42.569Z","avatar_url":"https://github.com/ohbarye.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RouteMechanic\n[![Gem Version](https://badge.fury.io/rb/route_mechanic.svg)](https://badge.fury.io/rb/route_mechanic)\n[![Build Status](https://github.com/ohbarye/route_mechanic/workflows/test/badge.svg?branch=master)](https://github.com/ohbarye/route_mechanic/actions?query=workflow%3Atest)\n\nNo need to maintain Rails' routing tests manually. RouteMechanic automatically detects broken routes and missing action methods in controllers once you've finished installation.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngroup :test do\n  gem 'route_mechanic'\nend\n```\n\nAnd then execute:\n\n```shell\n$ bundle install\n```\n\n## Usage\n\nRouteMechanic is available for both RSpec and MiniTest.\n\nAll you have to do is to add just one test case that keeps your application's routes not broken. Then, RouteMechanic will get to report 2 types of broken routes.\n\n1. Unused actions\n    - Your application has the controller and the action method but `config/routes.rb` doesn't have corresponding settings.\n2. Unused routes\n    - Your application's `config/routes.rb` has a routing declaration but no controller has a corresponding action method.\n\n### RSpec\n\nJust add one test file that has only one test case using `have_valid_routes` matcher.\n\n```ruby\nRSpec.describe 'Rails.application', type: :routing do\n  it \"fails if application does not have valid routes\" do\n    expect(Rails.application).to have_valid_routes\n  end\nend\n```\n\nIf you'd like to test unused actions and unused routes separately or test only one of them, there're matchers to do so.\n\n```ruby\nRSpec.describe 'Rails.application', type: :routing do\n  it \"fails if application has unused actions\" do\n    expect(Rails.application).to have_no_unused_actions\n  end\n\n  it \"fails if application has unused routes\" do\n    expect(Rails.application).to have_no_unused_routes\n  end\nend\n```\n\n### MiniTest\n\nJust add one test file like below.\n\n```ruby\nclass RoutingTest \u003c Minitest::Test\n  include ::RouteMechanic::Testing::Methods\n\n  def test_that_application_has_correct_routes\n    assert_all_routes\n  end\nend\n```\n\nIf you'd like to test unused actions and unused routes separately or test only one of them, there're assertions to do so.\n\n```ruby\nclass RoutingTest \u003c Minitest::Test\n  include ::RouteMechanic::Testing::Methods\n\n  def test_that_application_has_no_unused_actions\n    assert_no_unused_actions\n  end\n\n  def test_that_application_has_no_unused_routes\n    assert_no_unused_routes\n  end\nend\n```\n\n### What if RouteMechanic detects broken routes?\n\nIt tells you broken routes as follows.\n\n```ruby\n  0) Rail.application fails if application does not have valid routes\n     Failure/Error: expect(Rails.application.routes).to have_valid_routes\n\n       [Route Mechanic]\n         No route matches to the controllers and action methods below\n           UsersController#unknown\n         No controller and action matches to the routes below\n           GET    /users/:user_id/friends(.:format) users#friends\n           GET    /users(.:format)                  users#index\n           DELETE /users/:id(.:format)              users#destroy\n     # ./spec/rspec/matchers_spec.rb:8:in `block (2 levels) in \u003ctop (required)\u003e'\n\n1 examples, 1 failure, 0 passed\n```\n\n## Motivation\n\nI believe most Rails developers write request specs instead of routing specs, and you might wonder what's worth to automate routing specs. Having said that, I can come up with some use-cases of this gem.\n\n1. When your project is kinda aged and none knows which route is alive and which one is dead.\n    - =\u003e You can detect dead code by using this gem.\n2. When your application doesn't have enough request specs (even controller specs).\n    - =\u003e This gem could be a good start point to increase tests to ensure routing is valid.\n3. When you try to make a big refactor of `config/routes.rb`.\n    - =\u003e It's a burden to run all request specs during refactoring. This could save your time.\n4. When you're compelled to write routing specs by any pressure. ;-)\n    - =\u003e Set you free from tedious work!\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the RouteMechanic project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/route_mechanic/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohbarye%2Froute_mechanic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohbarye%2Froute_mechanic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohbarye%2Froute_mechanic/lists"}