<?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>Duplo &#187; spec</title>
	<atom:link href="http://kill-0.com/duplo/tag/spec/feed/" rel="self" type="application/rss+xml" />
	<link>http://kill-0.com/duplo</link>
	<description>Building Blocks &#38; Learning Experiences</description>
	<lastBuildDate>Fri, 05 Aug 2011 15:30:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Rspec 1.1.4 and Helper spec woes</title>
		<link>http://kill-0.com/duplo/2008/08/06/rspec-114-and-helper-spec-woes/</link>
		<comments>http://kill-0.com/duplo/2008/08/06/rspec-114-and-helper-spec-woes/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 04:11:57 +0000</pubDate>
		<dc:creator>ericw</dc:creator>
				<category><![CDATA[mildred]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[1.1.4]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[spec]]></category>

		<guid isPermaLink="false">http://kill-0.com/duplo/2008/08/06/rspec-114-and-helper-spec-woes/</guid>
		<description><![CDATA[I was having all sorts of problems upgrading Mildred to Rails 2.1.  A lot of the errors I was seeing were like the following: ArgumentError in 'TracksController downloading a track by admin should not be a redirection' wrong number of arguments (0 for 1) /Users/ewollesen/src/mildred/app/models/track.rb:52:in `title' /Users/ewollesen/src/mildred/app/models/track.rb:52:in `filename' /Users/ewollesen/src/mildred/app/controllers/tracks_controller.rb:49:in `download' ./spec/controllers/tracks_controller_spec.rb:82: It took me a [...]]]></description>
			<content:encoded><![CDATA[<p>I was having all sorts of problems upgrading Mildred to Rails 2.1.  A lot of the errors I was seeing were like the following:</p>
<pre><code>ArgumentError in 'TracksController downloading a track by admin should not be a redirection'
wrong number of arguments (0 for 1)
/Users/ewollesen/src/mildred/app/models/track.rb:52:in `title'
/Users/ewollesen/src/mildred/app/models/track.rb:52:in `filename'
/Users/ewollesen/src/mildred/app/controllers/tracks_controller.rb:49:in `download'
./spec/controllers/tracks_controller_spec.rb:82:</code></pre>
<p>It took me a good while to figure out what was going on.  The error was strange because as far as I knew, <code>title</code> was a database attribute in the Album model, which was a descendant of ActiveRecord.  There shouldn&#8217;t have been any arguments required.  Indeed, firing up my debugger and running <code>track.album.read_attribute(:title)</code> returned the expected result of &#8220;Test Album 1&#8243;.  I was very puzzled.</p>
<p>I realized that my title method was being overridden, but by what?  I started feeding the title method random arguments in the hopes of learning something new.  It wasn&#8217;t long before I got lucky:</p>
<pre><code>(rdb:1) e track.album.title("x")
NoMethodError Exception: undefined method `content_tag' for #&lt;Album:0x3d5bbfc&gt;</code></pre>
<p>That tipped me off as to what was overriding my title method.  The <code>content_for</code> is part of a pattern I use to set a view&#8217;s title in the layout via a method called <code>title</code> in my <a href="http://www.xmtp.net/websvn/filedetails.php?repname=mildred&amp;path=%2Fmildred_rails%2Fbranches%2Frails-2.1%2Fapp%2Fhelpers%2Fapplication_helper.rb&amp;rev=552&amp;sc=0"><code>ApplicationHelper</code></a>.  This made me think of how in Rspec 1.1.4, a Helper module is no longer included by default.  I popped over to my <a href="http://www.xmtp.net/websvn/filedetails.php?repname=mildred&amp;path=%2Fmildred_rails%2Fbranches%2Frails-2.1%2Fspec%2Fhelpers%2Fapplication_helper_spec.rb&amp;rev=0&amp;sc=0"><code>application_helper_spec.rb</code></a> and found something similar to this:</p>
<pre><code>require File.dirname(__FILE__) + '/../spec_helper'

include ApplicationHelper

describe "ApplicationHelper" do</code></pre>
<p>This needed to be changed to:</p>
<pre><code>require File.dirname(__FILE__) + '/../spec_helper'

describe "ApplicationHelper" do

  include ApplicationHelper</code></pre>
<p>Then all was well.  Whew.  Just to be sure I didn&#8217;t run into this sort of thing again, I went ahead and made sure that all of my other Helper specs followed this paradigm.</p>
<p>This is the second time I&#8217;ve run into an issue where RSpec had overridden some seemingly random method in some seemingly random object.  I guess there&#8217;s a lot of magic in there that I don&#8217;t have my head wrapped around yet.  I just wish it were easier to spot!</p>
]]></content:encoded>
			<wfw:commentRss>http://kill-0.com/duplo/2008/08/06/rspec-114-and-helper-spec-woes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

