Skip to content

Instantly share code, notes, and snippets.

@mikegrassotti
Created April 2, 2015 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikegrassotti/ee252a3c9e84e70c970c to your computer and use it in GitHub Desktop.
Save mikegrassotti/ee252a3c9e84e70c970c to your computer and use it in GitHub Desktop.
Generate a list of routes in a rails app (to automate testing)
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