[rspec-users] any way to have a different SOUND from growl for a 'pass' rather than a 'fail' when using "./script/autospec" ???

Greg Hauptmann greg.hauptmann.ruby at gmail.com
Mon Nov 10 19:03:41 EST 2008


I'm on Mac too - so it may be as simple as changing the Growl
Preferences to get this working then?
(assuming I'm using vanilla Rspec gem).

I've also customised (copy/pasted from a recommendation) my
~/.autotest file.   Is this an issue?  Does this file actually get
used now I'm using RSpec and "./script/autospec" (as opposed to just
using ZenTest's autotest)?

regards
Greg

--------------------------------------
Macintosh-2:myequity greg$ cat ~/.autotest
# -*- ruby -*-

# NOTE Copy this to your home folder as .autotest
#
# Originally from
http://wincent.com/knowledge-base/Setting_up_autotest_to_use_Growl
#
# Modifications:
#   * Minor refactoring to use .autotest_images directory
#     [Geoffrey Grosenbach http://peepcode.com]
#   * Test::Unit compatibility [Pat Nakajima]
#
module Autotest::Growl

 AUTOTEST_IMAGE_ROOT = "~/.autotest_images"

 def self.growl title, msg, img, pri=0, sticky=""
   # puts "GREGS: growlnotify -n autotest --image #{img} -p #{pri} -m
#{msg.inspect} #{title} #{sticky}"
   system "growlnotify -n autotest --image #{img} -p #{pri} -m
#{msg.inspect} #{title} #{sticky}"
 end

 def self.growl_fail(output)
   # puts "GREGS: growl FAIL, #{output}"
   growl "FAIL", "#{output}", "#{AUTOTEST_IMAGE_ROOT}/fail.png", 2
 end

 def self.growl_pass(output)
   # puts "GREGS: growl_pass PASS, #{output}"
   growl "Pass", "#{output}", "#{AUTOTEST_IMAGE_ROOT}/pass.png"
 end

 Autotest.add_hook :ran_command do |at|

   results = [at.results].flatten.join("\n")

   if results.include? 'tests'
     output = results.slice(/(\d+)\s+tests?,\s*(\d+)\s+assertions?,\s*(\d+)\s+failures?(,\s*(\d+)\s+errors)?/)
     if output
       $~[3].to_i + $~[5].to_i > 0 ? growl_fail(output) : growl_pass(output)
     end
   else
     output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+not
implemented)?/)
     if output
       $~[2].to_i > 0 ? growl_fail(output) : growl_pass(output)
     end
   end
 end

end

------------------------------------------------------

On Tue, Nov 11, 2008 at 7:51 AM, Christopher Bailey
<chris at cobaltedge.com> wrote:
> I'm not sure what platform you're on, or if this is what you're after, but
> the .autospec I use on the Mac uses the built in speech stuff to say what
> happens at the end of an autotest run.  So, it tells me things like "all
> tests passed", or "tests passed" (depends on whether or not it ran the full
> suite, or just a changed file/spec), "some pending", and of course fails.  I
> use different voices depending on the results :)
> http://gist.github.com/23649
>
> On Sat, Nov 8, 2008 at 12:37 PM, Greg Hauptmann
> <greg.hauptmann.ruby at gmail.com> wrote:
>>
>> Hi,
>>
>> Is there any way to have a different SOUND from growl for a 'pass'
>> rather than a 'fail' when using "./script/autospec" ???
>>
>> thanks
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
>
>
> --
> Christopher Bailey
> Cobalt Edge LLC
> http://cobaltedge.com
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list