Nick Sieger: Tag anttag:blog.nicksieger.com,2005:TypoTypo2010-11-22T19:38:57+00:00Nick Siegerurn:uuid:e3f1c8a2-8050-44b8-a1f5-02cecb0ff92c2007-01-06T15:42:00+00:002010-11-22T19:38:57+00:00Continuous Integration Goodness(TM) for Your Ruby Project<p>As much as we’d like to think we live in a Ruby-glasses-colored world, the fact is there are plenty of neat toys out there that don’t know a bit about us. One that I’m currently enamoured with is <a href="http://confluence.atlassian.com/display/BAMBOO">Bamboo, Atlassian’s new continuous integration server</a>. But, most commercial CI products are aiming for a wider market, and that means Java and Ant. Ant and JUnit predate Rake and Test::Unit by a few years, so I’m afraid they beat us to the punch, so that now the <a href="http://ant.apache.org/manual/OptionalTasks/junit.html">JUnit Ant task’s</a> XML format is pretty much the first consideration for a continuous integration server to understand in order to display a test report for a build.</p>
<p>Where does that leave us Rubyists who want to play along with the bigs? <a href="http://svn.caldersphere.net/svn/main/ci_reporter">Right here!</a>. With support for not just <a href="http://blog.nicksieger.com/articles/tag/rspec">RSpec</a>, but Test::Unit too.</p>
<p>Right now, it’s packaged as a Rails plugin, because I’m lazy and I don’t need anything else right now. If you’re interested in a gem, please leave a comment. To install into your Rails app, the usual:</p>
<div class="typocode"><pre><code class="typocode_default ">./script/plugin install http://svn.caldersphere.net/svn/main/ci_reporter</code></pre></div>
<p>That’s it! Now all you have to do is have your CI server invoke an extra target before the main target that runs your tests.</p>
<p>For RSpec,</p>
<div class="typocode"><pre><code class="typocode_default ">rake ci:setup_rspec spec</code></pre></div>
<p>will leave one XML file per context in the <code>spec/reports</code> directory (creating it if it doesn’t exist).</p>
<p>For Test::Unit,</p>
<div class="typocode"><pre><code class="typocode_default ">rake ci:setup_testunit test</code></pre></div>
<p>will leave one XML file per test case class in the <code>test/reports</code> directory.</p>
<p>Most CI servers have configuration telling them where to look for test reports. Simply plug in one of these directories, and you’re set. Now sit back and watch your test or spec failures get tracked in your automated builds.</p>
<p><img src="/files/test-results.png" alt="test results" title="test results"/></p>