In the course of time, I found myself wanting to run RSpec automatically in response to file changes. I found a nice tool called fswatch to handle the file events, but I wanted a "smarter" pipeline. Following the Unix philosophy, I wrote a few tiny command line tools which I've provided the source to.
specname
— maps a file in a rails project to its corresponding spec file.debounce
— makes sure multiple rapid saves don't trigger as many RSpec runs.throttle
— could be used to collect multiple file changes into one RSpec run, but I haven't figured that last part out yet.
The core functions are fully generic and have no dependencies on anything but Foundation, so they could be easily incorporated into a larger project if there's a use for them.
You can quickly run these scripts or install them as binaries using JohnSundell/Marathon.
marathon install debounce.swift