<?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>Wed, 22 Sep 2010 22:11:53 +0000</lastBuildDate>
	<language>es</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Notificaciones de Autospec en Gnome</title>
		<link>http://automate-everything.com/lang/es/2009/08/gnome-and-autospec-notifications</link>
		<comments>http://automate-everything.com/lang/es/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="es">Últimamente ando muy metido en TDD y ya que he conseguido echar a andar las notificaciones de autospec con Ubuntu (Jaunty 9.04) me gustaría compartirlo por aquí porque el post en el que lo encontré ya no está disponible.</span></p>
<p><br />
<span lang="es">Uso XFCE pero debe funcionar igualmente con Gnome. Este es un screenshot del resultado final:</span></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><br />
<span lang="es">En primer lugar, necesitas la gema ZenTest. Probablemente ya la tengas:</span></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><br />
<span lang="es">Ahora instala el paquete <em>libnotify-bin</em>:</span></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><br />
<span lang="es">Y aquí está el truco, crea un fichero llamado <em>~/.autotest</em> con esto:</span></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;">&#40;</span>,\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>\spending?<span style="color:#006600; font-weight:bold;">|</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    full_sentence, green, failures, garbage, pending = $~.<span style="color:#9900CC;">to_a</span>.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&amp;</span>:to_i<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> output
      <span style="color:#9966CC; font-weight:bold;">if</span> failures <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;">elsif</span> pending <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span>
        notify <span style="color:#996600;">&quot;Pending&quot;</span>, <span style="color:#996600;">&quot;#{output}&quot;</span>, <span style="color:#996600;">&quot;#{image_root}/pending.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>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>


<p><span lang="es">Como puedes ver uso fail.png y pass.png para añadir esos smiles. Puedes descargarlos aquí y copiarlos a <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="es">Haz que tus tests sean de color verde y pilla una cerveza : )</span></p>

<p><span lang="es">Update: Añadida la gema redgreen y cambiado &#8220;require redgreen&#8221; como sugirieron Rodigo Flores y rakk. Gracias!</span></p>

<p><span lang="es">Update: Corregido <code>&#62;</code> escapado por error en el código. Gracias a Martin y Hunter por los comentarios.</span></p>
<p><br />
<span lang="es">Update: El script ahora soporta ejemplos pendientes. Gracias a Andy.</span></p>
<p><br />
<span lang="es">Update: Eliminado un end que sobraba. Gracias a Andy de nuevo.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://automate-everything.com/lang/es/2009/08/gnome-and-autospec-notifications/feed</wfw:commentRss>
		<slash:comments>76</slash:comments>
		</item>
	</channel>
</rss>

