Skip to content

Instantly share code, notes, and snippets.

@MichaelDimmitt
Last active November 15, 2023 17:10
Show Gist options
  • Save MichaelDimmitt/14893f5b1348a435bd9f7cad262c15de to your computer and use it in GitHub Desktop.
Save MichaelDimmitt/14893f5b1348a435bd9f7cad262c15de to your computer and use it in GitHub Desktop.
Quickly open all rails get routes ... for manual testing

Quickly open all rails get routes

... with developer console open.
... for manual testing. ... for a starting place on automating all of this info where you spy on console errors and failed network requests.

Disclaimer:
The open command only works on a mac computer...
To see the commands for other operating systems look here: https://gist.github.com/MichaelDimmitt/f9931a66bfc24e40e91aa4c8ec52cdd1

Instructions

  1. open google chrome, and dev tools, click the console tab.
  2. quit out of google chrome if you have it open this is needed to open future tabs with dev tools
  3. change the base url as needed for different environments.
  4. now you have all the tabs open but a lot of rails stuff is still not filled out
    a. I did not know how to fill out things like /:signed_id/*filename(.:format)
    b. manually update these values

step 5 . enjoy!

Example output:

example

#!/bin/bash
# This code allows for pagination, 4 comments below say: "remove me to turn off pagination"
{
paginationCursor=1; # remove me to turn off pagination
paginationScalar=5; # remove me to turn off pagination
baseURL="https://localhost";
listOfRoutes=$(
rails routes |
grep GET |
tail -n $(( paginationCursor * paginationScalar )) | # remove me to turn off pagination
head -n $paginationScalar | # remove me to turn off pagination
awk -F ' /' '{print $2}' | awk '{print $1}'
);
echo "$listOfRoutes" |
xargs -I {} echo $baseURL/{}
# xargs -I {} open -a "Google Chrome" $baseURL/{} --args --auto-open-devtools-for-tabs;
}
# ^ currently it prints all the constructed links:
# └-- uncomment the last line to have it open google chrome with the related links.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment