<?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>Lojic Technologies Blog &#187; rcov</title>
	<atom:link href="http://lojic.com/blog/tag/rcov/feed/" rel="self" type="application/rss+xml" />
	<link>http://lojic.com/blog</link>
	<description></description>
	<lastBuildDate>Fri, 25 Nov 2011 20:12:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setup shoulda and rcov for Rails 2.2.2</title>
		<link>http://lojic.com/blog/2009/02/26/setup-shoulda-and-rcov-for-rails-222/</link>
		<comments>http://lojic.com/blog/2009/02/26/setup-shoulda-and-rcov-for-rails-222/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 02:10:27 +0000</pubDate>
		<dc:creator>Brian Adkins</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rcov]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[shoulda]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://lojic.com/blog/?p=216</guid>
		<description><![CDATA[I had a few mis-configuration issues when setting up shoulda and rcov for a new Rails 2.2.2 project, so I thought I&#8217;d jot down a few notes (mini tutorial, quickstart) to help save others from burning time on what should be a simple task.
shoulda is a library build on Test::Unit that provides helpers, macros and [...]]]></description>
			<content:encoded><![CDATA[<p>I had a few mis-configuration issues when setting up shoulda and rcov for a new Rails 2.2.2 project, so I thought I&#8217;d jot down a few notes (mini tutorial, quickstart) to help save others from burning time on what should be a simple task.</p>
<p><a href="http://thoughtbot.com/projects/shoulda/">shoulda</a> is a library build on Test::Unit that provides helpers, macros and assertions to make testing easier. </p>
<p><a href="http://eigenclass.org/hiki/rcov">rcov</a> is a code coverage tool for Ruby.</p>
<p><strong>1. Install rcov</strong></p>
<pre>
sudo gem install rcov
</pre>
<p><strong>2. Install shoulda</strong></p>
<pre>
sudo gem install thoughtbot-shoulda --source=http://gems.github.com
</pre>
<p><strong>3. Create your Rails project</strong></p>
<pre>
rails myapp
</pre>
<p><strong>4. Modify myapp/Rakefile</strong></p>
<pre>
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
require 'shoulda/tasks'
namespace :test do
  desc 'Measures test coverage'
  task :coverage do
    rm_f "coverage"
    rm_f "coverage.data"
    rcov = "rcov -Itest --rails --aggregate coverage.data -T -x \" rubygems/*,/Library/Ruby/Site/*,gems/*,rcov*\""
    system("#{rcov} --no-html test/unit/*_test.rb test/unit/helpers/*_test.rb")
    system("#{rcov} --no-html test/functional/*_test.rb")
    system("#{rcov} --html test/integration/*_test.rb")
    system("open coverage/index.html") if PLATFORM['darwin']
  end
end
</pre>
<p><strong>5. Modify myapp/test/test_helper.rb</strong></p>
<pre>
...
# Add the following line
require 'shoulda/rails'   # require 'shoulda' also worked
...
</pre>
<p><strong>Conclusion</strong><br />
After you&#8217;ve written some shoulda tests, you should be able to use the following rake commands: </p>
<pre>
rake test
rake test:units
rake shoulda:list    # display specs from shoulda tests
rake test:coverage   # run rcov and display code coverage
</pre>
]]></content:encoded>
			<wfw:commentRss>http://lojic.com/blog/2009/02/26/setup-shoulda-and-rcov-for-rails-222/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

