Nick Sieger: Tag autotest http://blog.nicksieger.com/articles/tag/autotest?tag=autotest en-us 40 do what you love Auto RSpec <p><em>Update: (2 months later) If you&#8217;re reading this, you&#8217;re probably interested in <a href="/articles/2006/11/15/rspec-autotest-now-a-rails-plugin">my Rails plugin for this</a> instead.</em></p> <p>Hot off the presses, after a few hours of hacking and tweaking, may I present Auto+RSpec, otherwise known as The Mashup of <a href="http://rspec.rubyforge.org/tools/rails.html">RSpec on Rails</a> and <a href="http://www.zenspider.com/ZSS/Products/ZenTest/">autotest</a>. This is not an official release of any sort, but &#8220;may work for you.&#8221; It&#8217;s not a clean hack, as it exposes some areas for autotest to grow if the maintainers decide to open it up to alternatives to Test::Unit. After spending a little time looking at the autotest code, I think it would be nice to allow hooks for autotest plugins to define project conventions (i.e., <code>@exceptions</code> and the <code>#tests_for_file</code> method) as well as a result parsing API.</p> <p>For now, if you&#8217;re an RSpec on Rails user, you can try this out as follows:</p> <ul> <li>Install <a href="http://www.zenspider.com/ZSS/Products/ZenTest/">ZenTest</a> if you haven&#8217;t already: <code>sudo gem install ZenTest</code>.</li> <li>Download <a href="http://svn.caldersphere.net/svn/main/rspec_autotest/trunk/lib/rspec_autotest.rb">rspec_autotest.rb</a> and put in your <code>vendor/plugins/rspec/lib</code> directory (you did say you&#8217;re using RSpec on Rails didn&#8217;t you?)</li> <li>Download <a href="http://svn.caldersphere.net/svn/main/rspec_autotest/trunk/tasks/rspec_autotest.rake">rspec_autotest.rake</a> and put in your <code>lib/tasks</code> directory</li> <li>Start <code>autotest</code> with rake by typing <code>rake spec:autotest</code></li> <li>Note: if you&#8217;re using RSpec 0.6, you might have better success with <a href="http://svn.caldersphere.net/svn/main/rspec_autotest/tags/rspec-0.6.0">the files located here</a>.</li> </ul> <p>Next steps for this will be to work out whether this code should live in RSpec on Rails or autotest, or some combination of those.</p> <p>Now, spec&#8217;ers, be off in search of that <strong>Red/Green/Refactor</strong> rhythm of which sage agilists speak!</p> <p><strong>Bonus tip</strong>: add the following code to your <code>.autotest</code> file to run <code>spec</code> with <code>rcov</code>:</p> <div class="typocode"><pre><code class="typocode_ruby "> <span class="constant">Autotest</span><span class="punct">.</span><span class="ident">add_hook</span> <span class="symbol">:initialize</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">at</span><span class="punct">|</span> <span class="comment"># run spec with rcov</span> <span class="keyword">if</span> <span class="ident">at</span><span class="punct">.</span><span class="ident">respond_to?</span> <span class="symbol">:spec_command</span> <span class="ident">at</span><span class="punct">.</span><span class="ident">spec_command</span> <span class="punct">=</span> <span class="punct">%{</span><span class="string">rcov --exclude &quot;lib/spec/.*&quot; -Ilib --rails &quot;/usr/lib/ruby/gems/1.8/gems/rspec-0.6.0/bin/spec&quot; -- --diff</span><span class="punct">}</span> <span class="keyword">end</span> <span class="keyword">end</span></code></pre></div> Wed, 13 Sep 2006 20:35:00 +0000 urn:uuid:52bf2e58-ea0e-4473-bad5-c7b42775bfee Nick Sieger http://blog.nicksieger.com/articles/2006/09/13/auto-rspec testing ruby rails ruby autotest rspec testing http://blog.nicksieger.com/articles/trackback/59 RSpec Autotest for Standalone Projects <p>I know there has been some demand out there for a version of my <a href="/articles/2006/11/15/rspec-autotest-now-a-rails-plugin">RSpec Autotest Rails plugin</a> that works with standalone (non-Rails) projects, so I finally caved and coded it up. I really hope this does finally get accepted as <a href="https://rubyforge.org/tracker/?func=detail&amp;aid=6732&amp;group_id=419&amp;atid=1680">a patch to ZenTest</a> (nudge, nudge), but until it gets a more standard release, do try it out:</p> <ol> <li>Ensure you have ZenTest installed (<code>gem install ZenTest</code>).</li> <li><a href="http://svn.caldersphere.net/svn/main/rspec_autotest/trunk/lib/rspec_autotest.rb">Download the rspec_autotest.rb file here</a> and put it in the <code>spec</code> directory of your project.</li> <li>Add this snippet of code into your <code>Rakefile</code>, and <code>rake spec:autotest</code> as usual.</li> </ol> <div class="typocode"><pre><code class="typocode_ruby "><span class="ident">namespace</span> <span class="symbol">:spec</span> <span class="keyword">do</span> <span class="ident">task</span> <span class="symbol">:autotest</span> <span class="keyword">do</span> <span class="ident">require</span> <span class="punct">'</span><span class="string">./spec/rspec_autotest</span><span class="punct">'</span> <span class="constant">RspecAutotest</span><span class="punct">.</span><span class="ident">run</span> <span class="keyword">end</span> <span class="keyword">end</span></code></pre></div> <p>Once again, happy spec&#8217;ing, and let me know of any issues you have with it.</p> Tue, 30 Jan 2007 02:16:00 +0000 urn:uuid:ea568e8e-e6f4-4fb7-80df-8da5f50065b9 Nick Sieger http://blog.nicksieger.com/articles/2007/01/30/rspec-autotest-for-standalone-projects ruby rspec autotest http://blog.nicksieger.com/articles/trackback/204