<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: autotest code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 25 Jul 2008 00:46:04 GMT</pubDate>
    <description>DZone Snippets: autotest code</description>
    <item>
      <title>Modified Growl support for Ruby autotest</title>
      <link>http://snippets.dzone.com/posts/show/4514</link>
      <description># This code is a different approach to using Growl notifications (Mac OS X)&lt;br /&gt;# with autotest for Ruby.&lt;br /&gt;# The code can be added to ~/.autotest&lt;br /&gt;# Be sure to comment out "require 'autotest/growl'" if you have that line&lt;br /&gt;# in your .autotest file.&lt;br /&gt;# Based on ZenTest-3.6.1/lib/autotest/growl.rb&lt;br /&gt;# Requires the 2 rails png graphics found at:&lt;br /&gt;# http://blog.internautdesign.com/2006/11/12/autotest-growl-goodness&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;module Autotest::Growl&lt;br /&gt;  # save the name of the working directory (e.g., the app name)&lt;br /&gt;  # to be used as a key to identify this particular run of autotest&lt;br /&gt;  # so the same growl notification will be reused for updates,&lt;br /&gt;  # instead of a new growl window for every posting.&lt;br /&gt;  @@current_directory_name = Dir.pwd.match(/([^\/]+)\z/).to_s&lt;br /&gt;  def self.growl title, msg, pri=0&lt;br /&gt;    title += " in #{@@current_directory_name}"&lt;br /&gt;    msg += " at #{Time.now}"&lt;br /&gt;    # ### change the path to the directory for the png graphics:&lt;br /&gt;    system "growlnotify -n autotest #{pri &gt; 0 ? '-s ' : ''}--image /Users/grant/Pictures/rails_#{pri &gt; 0 ? 'fail' : 'ok'}.png -p #{pri} -d '#{Dir.pwd}' -m #{msg.inspect} #{title}"&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  Autotest.add_hook :run do  |at|&lt;br /&gt;    growl "autotest running", "Started"&lt;br /&gt;  end&lt;br /&gt;  Autotest.add_hook :red do |at|&lt;br /&gt;    growl "Tests Failed", "#{at.files_to_test.size} tests failed", 2&lt;br /&gt;  end&lt;br /&gt;  Autotest.add_hook :green do |at|&lt;br /&gt;    growl "Tests Passed", "Tests passed", -2 if at.tainted&lt;br /&gt;  end&lt;br /&gt;  Autotest.add_hook :all_good do |at|&lt;br /&gt;    growl "Tests Passed", "All tests passed", -2 if at.tainted&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 09 Sep 2007 13:22:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4514</guid>
      <author>grantneufeld (Grant Neufeld)</author>
    </item>
    <item>
      <title>.autotest file</title>
      <link>http://snippets.dzone.com/posts/show/3718</link>
      <description>&lt;code&gt;&lt;br /&gt;require 'autotest/redgreen'&lt;br /&gt;require 'autotest/timestamp'&lt;br /&gt;#require 'autotest/growl'&lt;br /&gt;&lt;br /&gt;#require 'autotest/html_report'&lt;br /&gt;#require 'autotest/kdenotify'&lt;br /&gt;#require 'autotest/menu'&lt;br /&gt;#require 'autotest/pretty'&lt;br /&gt;#require 'autotest/snarl'&lt;br /&gt;&lt;br /&gt;# Sort-of from http://blog.labratz.net/articles/2006/09/13/growl-autotest-rails-with-zentest-3-4-0&lt;br /&gt;def growl(title, msg, pri=0, stick="", image="")&lt;br /&gt;  image_arg = (!image.empty?) ? "--image #{image}" : ""&lt;br /&gt;  system "growlnotify -n autotest #{image_arg} -p #{pri} -m #{msg.inspect} #{title} #{stick}" &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;Autotest.add_hook :red do |at|&lt;br /&gt;  growl("Tests Failed", "#{at.files_to_test.size} tests failed", 2, "", "/Applications/Mail.app/Contents/Resources/Caution.tiff")&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;Autotest.add_hook :green do |at|&lt;br /&gt;  growl("Tests Passed", "All tests passed", -2, "", "/Applications/Mail.app/Contents/Resources/certificate.tiff") #if at.tainted&lt;br /&gt;end  &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 23 Mar 2007 10:31:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3718</guid>
      <author>caffo ()</author>
    </item>
  </channel>
</rss>
