Adding sound to your .autotest

Being a person with a keen auditory sense, I wanted my autotest to give me sonic feedback as well as colored growl images.

The sndplay utility I have compiled as a universal binary comes from snd (a handy app I used all the time when I was at CCRMA) sndplay has the nice feature of controlling the volume, which is important for toning down the annoyance factor.

Here are the fun audio files that I use in my .autotest. And here is the code:


require 'autotest/redgreen'

module Autotest::Growl
  def self.growl title, msg, img, pri=0, stick="" 
    system "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title} #{stick}" 
  end

  Autotest.add_hook :ran_command do |at|
    output = at.results.to_s.slice(/(\d+).*errors/)
    if output =~ /ns.*[1-9]/
      system "~/bin/sndplay ~/Library/autotest/bonk.wav -volume 0.5" 
      growl "Test Results", "#{output}", '~/Library/autotest/rails_fail.png', 2 #, "-s" 
    else
      system "~/bin/sndplay ~/Library/autotest/om.aiff -volume 0.1"    
      growl "Test Results", "#{output}", '~/Library/autotest/rails_ok.png'
    end
  end
end

1/29/08 UPDATE: The autotest API has been updated to have sound playback hooks… examples here.

actionmailer ActionView ajax alphadecimal audio autotest BDD blocks capistrano ssh ruby controller css dashboard widget delegate dog puppy naming name DRM email obfuscation exceptions factory pattern filemerge find and replace finder fink fixtures fun gem google maps helper helpers imagemagick Intertrust javascript logo math meetup model openssl OS X patch Pioneer Electronics plugin polymorphism prototype.js rails rake rmagick RSA encryption ruby script shoulda subversion SyncTV TDD testing textmate tricks unique hashes unix shell validation view yaml zebra stripes