Running Tests Quickly
So I was not having very much fun with Guard.
Having to install the gem. Having to write/alter the watch paths. Then having to put exceptions to tell it when not to run.
Ideally I would double-tap my esc key to run the tests any time I want. The test would run, and my cursor would never have to leave the code I was writing.
Keyboard Maestro was the answer.
No, it’s not free, but I’m glad I bought it. This is just one of hundreds of automations I’ve created with it. Yeah there are free copies floating around but you are a well paid developer, right?
Within an hour you should be able to figure it out and build the workflow seen below. Or just download this macro, import it into KM and see if it works.
https://dl.dropboxusercontent.com/u/2048705/run_rspec.kmmacros
How it works:
- You double tap the esc key (or choose any other key you like)
-
Focus will shift to the app you have designated as your testing terminal. Terminal, in my case.
A. I use iTerm2 with multiple tabs for my coding tasks. Server, bash, rails console, etc.
B. I chose the default Terminal for running tests, and it displays on a different screen than my iTerm window.
C. With a little more effort, it might be possible for Keyboard Maestro to detect one particular window of iTerm2, and to leave the others alone (AHK can do this on Windows), but choosing a different Terminal app altogether was the simplest solution for now.
- Command-K clears the testing screen.
- Your tests are run.
- Focus is returned to your code.