Freelance developer, and designer

Automate Your Tests with Observr

If you're like me, you should hate switching from editor-to-terminal then running tests and back to the editor again.

I've tried making my own guard and even used Node's chokidar module to watch the directory and run the test every time a certain file extension is saved.

I was content with chokidar for a while until sadly, it's standard output doesn't print out terminal colors.


Observr, the descendant of Watchr, is a ruby gem which watches a certain directory and well, you can pretty much do anything.


You can add it to your Gemfile

gem 'observr'

Or just install it globally

$ sudo gem install observr


Create your ruby file. I usually just name it watch.rb or phpspec.rb

def run_phpspec

  command = "`which phpspec` run --format=pretty --no-code-generation -v";



watch('.*\.php')  { |data| run_phpspec }

Run Observr

# Gemfile execution
$ bundle exec observr watch.rb

# global
$ observr watch.rb

When you create new files however, while Observr is already running, you have to restart the watcher to add the new files to the watch list.

There you go, no more switching windows which may save you 5 or 6 keystrokes. You're welcome. :)