<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Talk Like A Duck: Qui ipso probo probatur?</title>
    <link>http://talklikeaduck.denhaven2.com/articles/2007/07/14/qui-ipso-probo-probatur</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>In Ruby, it's not the dog, it's the tricks!</description>
    <item>
      <title>Qui ipso probo probatur?</title>
      <description>&lt;p&gt;The other day I was working on adding support for user selected time-zones to an existing rails app for a client.  As usual I was doing test-first development. One of the things that makes rails such a pleasure is that a good set of tests give confidence that you aren&amp;#8217;t breaking &amp;#8220;legacy&amp;#8221; code.&lt;/p&gt;
&lt;p&gt;
I also use, and really like, the &lt;a href="http://www.vim.org/scripts/script.php?script_id=1567"&gt;rails plugin for vim&lt;/a&gt; which does lots of nice things like making navigation between the files of rails apps much easier.  It also has a nice feature which adds a :Rake command to vim which &amp;#8220;does the right&amp;#8221; thing contextually.  For example if you are editing a migration and enter :Rake, it runs rake db:migrate.  If you are in a test file it runs just the single test selected by the cursor, or just that test file if you aren&amp;#8217;t positioned to a particular test.&lt;/p&gt;
&lt;p&gt;
I was doing the latter, and my test was failing, and I was having a hard time debugging it.  I tried executing just that single test from the bash command line with:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;$ruby test/unit/my_test.rb -n&amp;quot;test_mytest&amp;quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
and it still failed, no surprise.  The same thing happened if I ran the entire test file, in fact, other tests which had worked before were now failing, and I was really mystified now because I didn&amp;#8217;t see how I had done anything which had a remote chance of breaking those.
&lt;p&gt;So I figured I probably should test everthing so:&lt;/p&gt;
&lt;typo:code&gt;
$rake test
&lt;/typo&gt;
&lt;p&gt;And, surprise of surprises, but &lt;strong&gt;every test worked&lt;/strong&gt;. Not only my failing unit tests, but the functional and integration tests as well.&lt;/p&gt;
&lt;p&gt;To make a long story short, the problem turned out to be that the tests were failing because, now that the particular model was sensitive to the user&amp;#8217;s timezone, it needed access to it&amp;#8217;s associated user model, and I hadn&amp;#8217;t told the testcase that the users fixture was needed.  Running the testcase in isolation, the users table wasn&amp;#8217;t being populated for the test case.  But running rake test, or rake test:units meant that other tests run before had left the data I needed behind.&lt;/p&gt;
&lt;p&gt;Just a little thing that makes fixtures less than ideal.&lt;/p&gt;</description>
      <pubDate>Sat, 14 Jul 2007 15:28:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:503f95d2-19dd-4bdf-b3be-a2c730e6c9c8</guid>
      <author>Rick DeNatale</author>
      <link>http://talklikeaduck.denhaven2.com/articles/2007/07/14/qui-ipso-probo-probatur</link>
      <category>ruby</category>
      <category>rails</category>
      <category>testing</category>
      <category>fixtures</category>
      <category>gotchas</category>
      <trackback:ping>http://talklikeaduck.denhaven2.com/articles/trackback/441</trackback:ping>
    </item>
  </channel>
</rss>
