<?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>Blog - ShiftEleven &#187; rake</title>
	<atom:link href="http://shifteleven.com/articles/tag/rake/feed" rel="self" type="application/rss+xml" />
	<link>http://shifteleven.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 19 Sep 2009 11:19:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0-alpha</generator>
		<item>
		<title>Customize Your Rake Files</title>
		<link>http://shifteleven.com/articles/2007/03/05/customize-your-rake-files</link>
		<comments>http://shifteleven.com/articles/2007/03/05/customize-your-rake-files#comments</comments>
		<pubDate>Tue, 06 Mar 2007 00:07:15 +0000</pubDate>
		<dc:creator>K. Adam Christensen</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[rcov]]></category>

		<guid isPermaLink="false">http://dev.fecalrod.com/?p=27</guid>
		<description><![CDATA[Rcov is a handy tool to make sure that your tests have at least run every line of code in your application.  This is very useful if you have forgotten to write a test for a method, or if inside of a method, you forgot to test a conditional statement.  Because I find [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://eigenclass.org/hiki.rb?rcov">Rcov</a> is a handy tool to make sure that your tests have at least run every line of code in your application.  This is very useful if you have forgotten to write a test for a method, or if inside of a method, you forgot to test a conditional statement.  Because I find this handy, I incorporate the <a href="http://blog.codahale.com/2006/05/26/rails-plugin-rails_rcov/">rcov plugin</a> in my rails applications.</p>
<p>Running <code>rake test:functionals:rcov</code>, my report shows me a long list of items, some of which I don&#8217;t want to see.  I don&#8217;t want to see the coverage of my models in the report.  I should get that report by running <code>rake test:units:rcov</code>.  Luckily, the plugin allows for me to set arguments like <code>SHOW_ONLY="app/models"</code>.  But get this, I&#8217;m lazy and I don&#8217;t want to type that argument let alone remember it every time I want to run the rcov tests. What to do?</p>
<p><span id="more-27"></span></p>
<h3>Rake It Up</h3>
<p>The options are simply environment variables.  By using <code>rake</code>, we can create some tasks that set these environment variables.  So here&#8217;s what mine looks like:</p>
<pre class="ruby" title="code">task :default_rcov_params_for_units do
  RCOV_PARAMS = ENV['RCOV_PARAMS'] = "--sort=coverage"
  SHOW_ONLY = ENV['SHOW_ONLY'] = "app/models|lib|app/concerns|app/helpers"
end

task :default_rcov_params_for_functionals do
  RCOV_PARAMS = ENV['RCOV_PARAMS'] = "--sort=coverage"
  SHOW_ONLY = ENV['SHOW_ONLY'] = "app/controllers"
end</pre>
<p>That means now I can do something like <code>rake default_rcov_params_for_units test:units:rcov</code>.  Good, but there is better.  We can have <code>default_rcov_params_for_units</code> become a prerequisite for test:units:rcov.  That will make it happen automagically.</p>
<pre class="ruby" title="code">namespace :test do
  namespace :units do
    desc 'With RCOV_PARAMS="--sort=coverage" SHOW_ONLY="app/models|lib|app/concerns|app/helpers"'
    task :rcov =&gt; [:default_rcov_params_for_units]
  end

  desc 'With RCOV_PARAMS="--sort=coverage" SHOW_ONLY="app/controllers"'
  namespace :functionals do
    task :rcov =&gt; [:default_rcov_params_for_functionals]
  end
end</pre>
<h3>Follow Up</h3>
<p>Tada! That was easy.  This is one example of customizing your rake profile.  Don&#8217;t be <a href="http://errtheblog.com/post/33">afraid to try other methods</a> as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://shifteleven.com/articles/2007/03/05/customize-your-rake-files/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
