<?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>A Tempest of Thoughts &#187; Testing</title>
	<atom:link href="http://tempe.st/category/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://tempe.st</link>
	<description>aka blog.to_int(:inig)</description>
	<lastBuildDate>Thu, 07 Apr 2011 08:24:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>How I made Autotest RedGreen and Growl party together</title>
		<link>http://tempe.st/2008/05/how-i-made-autotest-redgreen-and-growl-party-together/</link>
		<comments>http://tempe.st/2008/05/how-i-made-autotest-redgreen-and-growl-party-together/#comments</comments>
		<pubDate>Sat, 31 May 2008 11:22:19 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[autotest]]></category>
		<category><![CDATA[growl]]></category>
		<category><![CDATA[redgreen]]></category>

		<guid isPermaLink="false">http://tempe.st/?p=217</guid>
		<description><![CDATA[If you&#8217;re like me and like autotest as a sort of private continous integration system, and if you like pretty output, you will probably have used some kind of autotest + redgreen and/or growl. Unfortunately I had strange quirks in my growl notifications. Sometimes they worked, sometimes they didn&#8217;t (I was using the standard :ran_command [...]]]></description>
			<content:encoded><![CDATA[	<p>If you&#8217;re like me and like autotest as a sort of private continous integration system, and if you like pretty output, you will probably have used some kind of autotest + redgreen and/or growl.</p>
	<p>Unfortunately I had strange quirks in my growl notifications. Sometimes they worked, sometimes they didn&#8217;t (I was using the standard :ran_command autotest hook at the time), so I switched to the newer :red and :green hooks, and only worsened the problem. No matter what the test output was, I always got a green notification.</p>
	<p>I was able to trace the problem to the redgreen gem. Its colorized output wasn&#8217;t being recognized correctly by autotest and it kept thinking everything was ok.</p>
	<p>A little ruby fiddling and this is my new improved (and working!) .autotest file:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># -*- ruby -*-</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">module</span> <span style="color:#6666ff; font-weight:bold;">Autotest::RedGreen</span>
  Autotest.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:alias_method</span>, <span style="color:#ff3333; font-weight:bold;">:real_ruby</span>, <span style="color:#ff3333; font-weight:bold;">:ruby</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  Autotest.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:define_method</span>, <span style="color:#ff3333; font-weight:bold;">:ruby</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|*</span>args<span style="color:#006600; font-weight:bold;">|</span>
      real_ruby <span style="color:#006600; font-weight:bold;">+</span> <span style="color:#006600; font-weight:bold;">%</span><span style="color:#006600; font-weight:bold;">&#91;</span> <span style="color:#006600; font-weight:bold;">-</span>rrubygems <span style="color:#006600; font-weight:bold;">-</span>e <span style="color:#996600;">&quot;require 'redgreen'&quot;</span> <span style="color:#006600; font-weight:bold;">&#93;</span> 
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># Clean the output so other modules can work correctly</span>
  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>
    at.<span style="color:#9900CC;">results</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>r<span style="color:#006600; font-weight:bold;">|</span>
      r.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\0</span>33[31m&quot;</span>, <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      r.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\0</span>33[32m&quot;</span>, <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      r.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\0</span>33[33m&quot;</span>, <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      r.<span style="color:#CC0066; font-weight:bold;">gsub!</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\0</span>33[0m&quot;</span>, <span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</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;">module</span> <span style="color:#6666ff; font-weight:bold;">Autotest::Growl</span>
  AUTOTEST_IMAGE_ROOT = <span style="color:#996600;">&quot;~/.autotest_images&quot;</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">growl</span><span style="color:#006600; font-weight:bold;">&#40;</span>title, msg, img, pri=<span style="color:#006666;">0</span>, sticky=<span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;growlnotify -n autotest --image #{img} -p #{pri} -m '#{msg.inspect} #{title}' #{sticky}&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;">:red</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>
    growl<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;FAIL&quot;</span>, <span style="color:#996600;">&quot;#{get_results(at)}&quot;</span>, <span style="color:#996600;">&quot;#{AUTOTEST_IMAGE_ROOT}/fail.png&quot;</span>, <span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#41;</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;">:green</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>
    growl<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;Pass&quot;</span>, <span style="color:#996600;">&quot;#{get_results(at)}&quot;</span>, <span style="color:#996600;">&quot;#{AUTOTEST_IMAGE_ROOT}/pass.png&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  private
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">get_results</span><span style="color:#006600; font-weight:bold;">&#40;</span>at<span style="color:#006600; font-weight:bold;">&#41;</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>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">if</span> results.<span style="color:#9966CC; font-weight:bold;">include</span>? <span style="color:#996600;">'tests'</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>\s<span style="color:#006600; font-weight:bold;">+</span>tests?,\s<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>\s<span style="color:#006600; font-weight:bold;">+</span>assertions?,\s<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>\s<span style="color:#006600; font-weight:bold;">+</span>failures?<span style="color:#006600; font-weight:bold;">&#40;</span>,\s<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>\s<span style="color:#006600; font-weight:bold;">+</span>errors<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>
    <span style="color:#9966CC; font-weight:bold;">else</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>\s<span style="color:#006600; font-weight:bold;">+</span>examples?,\s<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>\s<span style="color:#006600; font-weight:bold;">+</span>failures?<span style="color:#006600; font-weight:bold;">&#40;</span>,\s<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>\s<span style="color:#006600; font-weight:bold;">+</span><span style="color:#9966CC; font-weight:bold;">not</span> implemented<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>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    output
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Esclusioni</span>
Autotest.<span style="color:#9900CC;">add_hook</span> <span style="color:#ff3333; font-weight:bold;">:initialize</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>
  <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#123;</span>.<span style="color:#9900CC;">hg</span> .<span style="color:#9900CC;">git</span> .<span style="color:#9900CC;">svn</span> stories tmtags Rakefile Capfile README spec<span style="color:#006600; font-weight:bold;">/</span>spec.<span style="color:#9900CC;">opts</span> spec<span style="color:#006600; font-weight:bold;">/</span>rcov.<span style="color:#9900CC;">opts</span> vendor<span style="color:#006600; font-weight:bold;">/</span>gems autotest svn<span style="color:#006600; font-weight:bold;">-</span>commit .<span style="color:#9900CC;">DS_Store</span> <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>exception<span style="color:#006600; font-weight:bold;">|</span>
    at.<span style="color:#9900CC;">add_exception</span><span style="color:#006600; font-weight:bold;">&#40;</span>exception<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  at.<span style="color:#9900CC;">add_mapping</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>spec\<span style="color:#006600; font-weight:bold;">/</span>defaults.<span style="color:#9900CC;">rb</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f, _<span style="color:#006600; font-weight:bold;">|</span>
    at.<span style="color:#9900CC;">files_matching</span> <span style="color:#006600; font-weight:bold;">%</span>r<span style="color:#006600; font-weight:bold;">%</span>^spec<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>controllers<span style="color:#006600; font-weight:bold;">|</span>helpers<span style="color:#006600; font-weight:bold;">|</span>lib<span style="color:#006600; font-weight:bold;">|</span>models<span style="color:#006600; font-weight:bold;">|</span>views<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#006600; font-weight:bold;">*</span>\.<span style="color:#9900CC;">rb</span>$<span style="color:#006600; font-weight:bold;">%</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

 
	<p>Our setup had apache as webserver so I don&#8217;t need any special code to restart the application. In addition to this recipe, made to deploy to production I also wrote a couple of tasks that shine during development. </p>
	<p>Drupal has the problem of storing most of the important stuff in the database, and if you do local development, showing the status of the work to your clients can be a chore. The following tasks allow you to easily dump the development db and import the dump to the staging server to show your progresses to your customers and allow testing the site:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Callbacks</span>
before <span style="color:#996600;">'deploy:start'</span>, <span style="color:#996600;">'drupal:db:import:production'</span>
&nbsp;
before <span style="color:#996600;">'deploy:restart'</span>, <span style="color:#996600;">'mikamai:permissions:fix'</span>, <span style="color:#996600;">'mikamai:production:symlink'</span>, <span style="color:#996600;">'drupal:configure:production'</span>
before <span style="color:#996600;">'deploy:start'</span>, <span style="color:#996600;">'mikamai:permissions:fix'</span>, <span style="color:#996600;">'mikamai:production:symlink'</span>, <span style="color:#996600;">'drupal:configure:production'</span>
before <span style="color:#996600;">'deploy:cold'</span>, <span style="color:#996600;">'drupal:db:dump:development'</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># DB Stuff</span>
&nbsp;
set <span style="color:#ff3333; font-weight:bold;">:mysqldump</span>, <span style="color:#996600;">&quot;/opt/local/bin/mysqldump5&quot;</span> <span style="color:#008000; font-style:italic;"># your path to mysqldump</span>
<span style="color:#008000; font-style:italic;"># local db credentials</span>
set <span style="color:#ff3333; font-weight:bold;">:local_db_user</span>, <span style="color:#996600;">&quot;root&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:local_db_password</span>, <span style="color:#996600;">&quot;&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:local_db_name</span>, <span style="color:#996600;">&quot;database&quot;</span>
<span style="color:#008000; font-style:italic;"># remote db credentials</span>
set <span style="color:#ff3333; font-weight:bold;">:db_user</span>, <span style="color:#996600;">&quot;user&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:db_password</span>, <span style="color:#996600;">&quot;secret&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:db_name</span>, <span style="color:#996600;">&quot;database&quot;</span>
&nbsp;
namespace <span style="color:#ff3333; font-weight:bold;">:drupal</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp;
  namespace <span style="color:#ff3333; font-weight:bold;">:configure</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    task <span style="color:#ff3333; font-weight:bold;">:production</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      sudo <span style="color:#996600;">&quot;cp #{latest_release}/sites/default/settings.production.php #{latest_release}/sites/default/settings.php&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    task <span style="color:#ff3333; font-weight:bold;">:development</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      sudo <span style="color:#996600;">&quot;cp #{latest_release}/sites/default/settings.development.php #{latest_release}/sites/default/settings.php&quot;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  namespace <span style="color:#ff3333; font-weight:bold;">:db</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    namespace <span style="color:#ff3333; font-weight:bold;">:dump</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      task <span style="color:#ff3333; font-weight:bold;">:development</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#CC00FF; font-weight:bold;">RuntimeError</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;failed dump&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">&quot;#{mysqldump} -u #{local_db_user} --password=#{local_db_password} #{local_db_name} &gt; dump.sql&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    namespace <span style="color:#ff3333; font-weight:bold;">:import</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      task <span style="color:#ff3333; font-weight:bold;">:production</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        ENV<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;FILES&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;dump.sql&quot;</span>
        deploy::upload
        run <span style="color:#996600;">&quot;mysql -u #{db_user} --password=#{db_password} #{db_name} &lt; #{latest_release}/dump.sql&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>



 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2008/05/how-i-made-autotest-redgreen-and-growl-party-together/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>VBLiteUnit saved my life</title>
		<link>http://tempe.st/2007/07/vbliteunit-saved-my-life/</link>
		<comments>http://tempe.st/2007/07/vbliteunit-saved-my-life/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 08:30:56 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/07/vbliteunit-saved-my-life/</guid>
		<description><![CDATA[I want to personally thank the guys at VBLiteUnit. Without their unit testing framework I wouldn&#8217;t have been able to catch and squash a bug in a vba product I coded for a client some time ago. The bug was stupid but difficult to catch because it altered a few record every ten or so [...]]]></description>
			<content:encoded><![CDATA[	<p>I want to personally thank the guys at <a href="http://vb-lite-unit.sourceforge.net/">VBLiteUnit</a>. Without their unit testing framework I wouldn&#8217;t have been able to catch and squash a bug in a vba product I coded for a client some time ago. </p>
	<p>The bug was stupid but difficult to catch because it altered a few record every ten or so in a long query that is used to pay people, so some people were getting double pay! Good for them but not for my client <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
	<p>I had never done testing in vba before so I started to write my own testing routines, then I decided to check google again for free testing frameworks for vba and found VBLiteUnit.</p>
	<p>62 asserts later the bug was found and killed without any remorse whatsoever <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/07/vbliteunit-saved-my-life/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test Driven RJS with ARTS</title>
		<link>http://tempe.st/2007/04/test-driven-rjs-with-arts/</link>
		<comments>http://tempe.st/2007/04/test-driven-rjs-with-arts/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 10:40:52 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/04/test-driven-rjs-with-arts/</guid>
		<description><![CDATA[If you&#8217;re like me, you like writing tests for your code. Writing tests is a nice thing to do and saves you a lot of headaches. Writing tests for Ruby on Rails is really simple, with the wonderful testing framework built in Rails, but things become less ideal when you need to write tests for [...]]]></description>
			<content:encoded><![CDATA[	<p>If you&#8217;re like me, you like writing tests for your code. Writing tests is a nice thing to do and saves you a lot of headaches. </p>
	<p>Writing tests for Ruby on Rails is really simple, with the wonderful testing framework built in Rails, but things become less ideal when you need to write tests for your RJS code. </p>
	<p>This morning I wanted to test the following snippet:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> add_file_field
  render <span style="color:#ff3333; font-weight:bold;">:update</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>page<span style="color:#006600; font-weight:bold;">|</span>
    page.<span style="color:#9900CC;">remove</span> <span style="color:#996600;">&quot;link_to_add_#{params[:attachment_type]}&quot;</span>
    page.<span style="color:#9900CC;">insert_html</span> <span style="color:#ff3333; font-weight:bold;">:bottom</span>,
                     params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:attachment_type</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
                     <span style="color:#ff3333; font-weight:bold;">:partial</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;#{params[:attachment_type]}_file_field&quot;</span>, 
                     <span style="color:#ff3333; font-weight:bold;">:locals</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>:index <span style="color:#006600; font-weight:bold;">=&gt;</span> params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:index</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_i</span><span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

	<p>But the test was failing and I didn&#8217;t know why. The <a href="http://glu.ttono.us/articles/2006/05/29/guide-test-driven-rjs-with-arts">ARTS Plugin</a> came to the rescue, allowing me to test the rjs response:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#9966CC; font-weight:bold;">def</span> test_add_file_field
    xhr<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:get</span>, <span style="color:#ff3333; font-weight:bold;">:add_file_field</span>, <span style="color:#ff3333; font-weight:bold;">:index</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">1</span>, <span style="color:#ff3333; font-weight:bold;">:attachment_type</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;plan&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    assert_response <span style="color:#ff3333; font-weight:bold;">:success</span>
    assert_rjs <span style="color:#ff3333; font-weight:bold;">:remove</span>, <span style="color:#996600;">&quot;link_to_add_plan&quot;</span>
    <span style="color:#008000; font-style:italic;"># more code here...</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

	<p>Unfortunately that didn&#8217;t help with my problem since the cause was not the RJS, I was simply forgetting to login in my setup method <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/04/test-driven-rjs-with-arts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

