Forum: RSpec any way to have a different SOUND from growl for a 'pass' rather than a 'fail' when using "./script/

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Greg H. (Guest)
on 2008-11-08 22:39
(Received via mailing list)
Hi,

Is there any way to have a different SOUND from growl for a 'pass'
rather than a 'fail' when using "./script/autospec" ???

thanks
Christopher B. (Guest)
on 2008-11-10 23:54
(Received via mailing list)
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 H. <
Greg H. (Guest)
on 2008-11-11 02:06
(Received via mailing list)
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_autot...
#
# Modifications:
#   * Minor refactoring to use .autotest_images directory
#     [Geoffrey Grosenbach http://peepcode.com]
#   * Test::Unit compatibility [Pat N.]
#
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 B.
Steven R. (Guest)
on 2008-11-11 03:58
(Received via mailing list)
On Nov 10, 2008, at 6:03 PM, Greg H. wrote:

> 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).

One easy way is to use qp - a command line utility for playing
QuickTIme sounds. It's been removed from it's original home, but you
can get it from the wayback machine:

go to http://www.archive.org/index.php

and search for:  http://www.ed.com/qp/QP.dmg.gz

then you can use qp in the script to play a sound file based on the
event.

SR
Greg H. (Guest)
on 2008-11-11 12:27
(Received via mailing list)
thanks Chris - the help in http://gist.github.com/23649 worked great

On Tue, Nov 11, 2008 at 7:51 AM, Christopher B.
This topic is locked and can not be replied to.