Created
April 2, 2015 19:31
-
-
Save mikegrassotti/ee252a3c9e84e70c970c to your computer and use it in GitHub Desktop.
Generate a list of routes in a rails app (to automate testing)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
requests = Rails.application.routes.routes. | |
map {|r| "#{r.verb} #{r.path.spec.to_s}"}. | |
map {|p| p.gsub /..*(GET|DELETE|POST|PATCH|PUT)..* /, '\1 '}. | |
grep(/ \/api\/admin/). | |
map {|path| path.gsub("(.:format)", ".json")}. | |
map {|path| path.gsub(":id", "1")} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment