<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Automate Everything &#187; RSpec</title>
	<atom:link href="http://automate-everything.com/category/rspec/feed/" rel="self" type="application/rss+xml" />
	<link>http://automate-everything.com</link>
	<description>Ruby, Linux and other hints, tips and tricks.</description>
	<lastBuildDate>Tue, 13 Jul 2010 06:36:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Gnome and Autospec Notifications</title>
		<link>http://automate-everything.com/lang/en/2009/08/gnome-and-autospec-notifications</link>
		<comments>http://automate-everything.com/lang/en/2009/08/gnome-and-autospec-notifications#comments</comments>
		<pubDate>Tue, 04 Aug 2009 15:38:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[RSpec]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://automate-everything.com/?p=45</guid>
		<description><![CDATA[I wanted to share how I set up autospec notifications on Ubuntu (Jaunty 9.04). I'm using XCFE but should work perfectly on Gnome as well.]]></description>
			<content:encoded><![CDATA[<p><span lang="en">I&#8217;m very keen on DBB with RSpec now and I wanted to share how I set up autospec notifications on Ubuntu (Jaunty 9.04) as long as the post I followed to do it is no longer available.</span></p>

<p><span lang="en">I&#8217;m using XCFE but should work perfectly on Gnome as well. This is an screenshot of what you&#8217;ll get in the end:</span><br />
</p>
<div id="attachment_46" class="wp-caption alignnone" style="width: 601px"><img class="size-full wp-image-46" title="autospec notification XFCE/Gnome" src="http://automate-everything.com/wp-content/uploads/2009/08/autospec.png" alt="autospec notification XFCE/Gnome" width="591" height="279" /><p class="wp-caption-text">autospec notification XFCE/Gnome</p></div>
<p><span lang="en">First you need the ZenTest gem, you probably already do:</span><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> ZenTest
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> redgreen</pre></div></div>

<p><span lang="en">Then install the <em>libnotify-bin</em> package:</span><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libnotify-bin</pre></div></div>

<p><span lang="en">Here is the trick. Create a file called <em>~/.autotest</em> with this:</span><br />
</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/bin/ruby</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'redgreen'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'autotest/timestamp'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">module</span> <span style="color:#6666ff; font-weight:bold;">Autotest::GnomeNotify</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">notify</span> title, msg, img
    <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;notify-send '#{title}' '#{msg}' -i #{img} -t 3000&quot;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  Autotest.<span style="color:#9900CC;">add_hook</span> <span style="color:#ff3333; font-weight:bold;">:ran_command</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>at<span style="color:#006600; font-weight:bold;">|</span>
    image_root = <span style="color:#996600;">&quot;~/.autotest_images&quot;</span>
    results = <span style="color:#006600; font-weight:bold;">&#91;</span>at.<span style="color:#9900CC;">results</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">flatten</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    results.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>\\e\<span style="color:#006600; font-weight:bold;">&#91;</span>\d<span style="color:#006600; font-weight:bold;">+</span>m<span style="color:#006600; font-weight:bold;">/</span>,<span style="color:#996600;">''</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    output = results.<span style="color:#9900CC;">slice</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\sexamples?,\s<span style="color:#006600; font-weight:bold;">&#40;</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span>\sfailures?<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">puts</span> output.<span style="color:#9900CC;">inspect</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> output
      <span style="color:#9966CC; font-weight:bold;">if</span> $~<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span>
        notify <span style="color:#996600;">&quot;FAIL&quot;</span>, <span style="color:#996600;">&quot;#{output}&quot;</span>, <span style="color:#996600;">&quot;#{image_root}/fail.png&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">else</span>
        notify <span style="color:#996600;">&quot;Pass&quot;</span>, <span style="color:#996600;">&quot;#{output}&quot;</span>, <span style="color:#996600;">&quot;#{image_root}/pass.png&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><span lang="en">As you can see I use the fail.png and pass.png images to show those cheesy smileys : ). You can download them here and copy them to <em>~/.autotest_images/</em>.</span></p>

<p><a href="http://automate-everything.com/wp-content/uploads/2009/08/autotest_images.zip">autotest_images.zip</a></p>
<p><span lang="en">Make your tests go green and have a beer! : )</span></p>

<p><span lang="en">Update: Added redgreen gem and changed &#8220;require redgreen&#8221; as Rodrigo Flores and rakk suggested. Thanks!</span></p>

<p><span lang="en">Update: Changed mistakenly escaped <code>&#62;</code>. Thanks to Martin y Hunter for the comments.</span></p>

]]></content:encoded>
			<wfw:commentRss>http://automate-everything.com/lang/en/2009/08/gnome-and-autospec-notifications/feed</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
	</channel>
</rss>
