ohbarye / route_mechanic Goto Github PK
View Code? Open in Web Editor NEWRouteMechanic detects broken routes with ease :train:
Home Page: https://rubygems.org/gems/route_mechanic
License: MIT License
RouteMechanic detects broken routes with ease :train:
Home Page: https://rubygems.org/gems/route_mechanic
License: MIT License
First, this gem internally runs 2 checks.
The main check process is done by 1, and it runs the 2 just in case. But the 2 causes some problems like #7 #9, and even if the 2 is skipped it can correctly report missing routes.
Therefore, I'm wondering if this gem should stop using assertions provided by Rails so that its behavior gets stable.
If there's a path that expects a parameter to be a specific format, it fails.
e.g.
scope ':locale', locale: /en|ja/ do
get '/locale_test' => 'users#index'
end
/en|ja/
,route_mechanic
always gives 1
as a parameter in the path.I came up with 2 ideas as follow.
assert_routes
since it's not the main work of this gem.I kinda want to choose the 2nd option because assert_*
cause some problems like this and #7.
Thank you @pocke for reporting.
Hi. Thanks for the great gem!
I'm trying to use this gem in my Rails application, but it raises an error with constraints
.
We can reproduce the problem with the simple patch to this repository.
diff --git a/fixtures/fake_app/rails_app.rb b/fixtures/fake_app/rails_app.rb
index 09e13d7..c2b1e3d 100644
--- a/fixtures/fake_app/rails_app.rb
+++ b/fixtures/fake_app/rails_app.rb
@@ -8,6 +8,10 @@ FakeApp.config.root = File.dirname(__FILE__)
FakeApp.initialize!
FakeApp.routes.draw do
+ constraints subdomain: /\A[0-9a-z-]+\z/ do
+ get '/constraints_test' => 'users#index'
+ end
+
resources :users do
get 'friends', to: :friends
end
$ bundle exec rake
# Running:
...F
Failure:
RouteMechanicTestingMethodsTest#test_that_fake_app_has_missing_routes [/home/pocke/ghq/github.com/ohbarye/route_mechanic/test/testing/methods_test.rb:63]:
--- expected
+++ actual
@@ -1,12 +1 @@
-"[Route Mechanic]
- No route matches to the controllers and action methods below
- UsersController#unknown
- No controller and action matches to the routes below
- GET /users/:user_id/friends(.:format) users#friends
- GET /users(.:format) users#index
- GET /users/new(.:format) users#new
- GET /users/:id/edit(.:format) users#edit
- GET /users/:id(.:format) users#show
- DELETE /users/:id(.:format) users#destroy
-
-"
+"No route matches \"/constraints_test\""
rails test /home/pocke/ghq/github.com/ohbarye/route_mechanic/test/testing/methods_test.rb:44
it prints No route matches "/constraints_test"
, but I think it is not an intentional error.
It is raised during the assert_routing
method call.
If there's a public method in a controller, route_mechanic
treats it as an action method that should have routes.
e.g.
# If we have a method like below,
class UsersController
def foo_helper
end
end
# it expects `users#foo_helper` to exist in routes
TBA ๐ค
Should users be able to ignore any action methods?
If a Rails project contains an engine, and that engine introduces both routes and matching actions into your application, then RouteMechanic will successfully see the routes, but fail the have_no_unused_routes
assertion incorrectly, because it cannot see the action.
I wonder if it's time to retire this gem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.