<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: object code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 29 Aug 2008 20:48:12 GMT</pubDate>
    <description>DZone Snippets: object code</description>
    <item>
      <title>Fix for nil object error in Rails test fixtures</title>
      <link>http://snippets.dzone.com/posts/show/1135</link>
      <description>If you're seeing errors like this when you run Rails tests:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# NoMethodError: You have a nil object when you didn't expect it!&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;You might need to edit test/test_helper.rb to make sure use_instantiated_fixtures is true:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;self.use_instantiated_fixtures = true&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Prior to 1.0, Rails automatically created instance variables out of fixtures. So if you had a fixture record named "foo", you could access it in your test as "@foo". As of 1.0, the default is to disable that feature, which breaks a lot of existing code. Mike Clark &lt;a href="http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting" title="Mike Clark's Weblog: Faster Testing with Rails 1.0"&gt;explains the change&lt;/a&gt;.</description>
      <pubDate>Wed, 11 Jan 2006 06:43:42 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1135</guid>
      <author>brainpipe ()</author>
    </item>
  </channel>
</rss>
