<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Blaix's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 12 Oct 2008 16:21:14 GMT</pubDate>
    <description>DZone Snippets: Blaix's Code Snippets</description>
    <item>
      <title>Rake task to run a single rails unit or functional test</title>
      <link>http://snippets.dzone.com/posts/show/2336</link>
      <description>// stolen from here: http://nubyonrails.com/articles/2006/07/28/foscon-and-living-dangerously-with-rake&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;##&lt;br /&gt;# Run a single test in Rails.&lt;br /&gt;#&lt;br /&gt;#   rake blogs_list&lt;br /&gt;#   =&gt; Runs test_list for BlogsController (functional test)&lt;br /&gt;#&lt;br /&gt;#   rake blog_create&lt;br /&gt;#   =&gt; Runs test_create for BlogTest (unit test)&lt;br /&gt;&lt;br /&gt;rule "" do |t|&lt;br /&gt;  if /(.*)_([^.]+)$/.match(t.name)&lt;br /&gt;    file_name = $1&lt;br /&gt;    test_name = $2&lt;br /&gt;    if File.exist?("test/unit/#{file_name}_test.rb")&lt;br /&gt;      file_name = "unit/#{file_name}_test.rb" &lt;br /&gt;    elsif File.exist?("test/functional/#{file_name}_controller_test.rb")&lt;br /&gt;      file_name = "functional/#{file_name}_controller_test.rb" &lt;br /&gt;    else&lt;br /&gt;      raise "No file found for #{file_name}" &lt;br /&gt;    end&lt;br /&gt;    sh "ruby -Ilib:test test/#{file_name} -n /^test_#{test_name}/" &lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 28 Jul 2006 17:23:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2336</guid>
      <author>blaix ()</author>
    </item>
  </channel>
</rss>
