<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Rails, Fixtures, the Test DB, and Test::Unit</title>
	<atom:link href="http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/</link>
	<description>Jamie Flournoy's Software Development Blog</description>
	<lastBuildDate>Fri, 19 Mar 2010 02:13:16 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: ActiveRecord: the Visual Basic of Object Relational Mappers at Pervasive Code</title>
		<link>http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/comment-page-1/#comment-1666</link>
		<dc:creator>ActiveRecord: the Visual Basic of Object Relational Mappers at Pervasive Code</dc:creator>
		<pubDate>Fri, 05 Oct 2007 02:08:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/#comment-1666</guid>
		<description>[...] with a combination of a plugin and some customization, described in detail in my previous post, Rails, Fixtures, the Test DB, and Test::Unit. With those changes, all test fixture data is preloaded in the right order (so constraints [...]</description>
		<content:encoded><![CDATA[<p>[...] with a combination of a plugin and some customization, described in detail in my previous post, Rails, Fixtures, the Test DB, and Test::Unit. With those changes, all test fixture data is preloaded in the right order (so constraints [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Le</title>
		<link>http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/comment-page-1/#comment-1448</link>
		<dc:creator>Alex Le</dc:creator>
		<pubDate>Sat, 22 Sep 2007 17:37:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/#comment-1448</guid>
		<description>I believe that my ActiveFixture can be utilized to solve this headache of yours (FYI: ActiveFixture reads the belongs_to tag in your models and do a graph-traversal to get the correct order of fixture insertions -- this means that fixtures are loaded based on their foreign-key constraints thus always be in the correct insertion sequence ).  

The Preloaded Fixtures main call to the fixture can just be replaced by ActiveFixture.load_fixtures(), e.g.

module PreloadFixtures
  def self.preload!
    ActiveFixture.load_fixtures()
  end
...
end

I&#039;ll do some more research and see how ActiveFixture can be utilized better then just a rake task.  The current SVN to activefixture is at 
http://activefixture.rubyforge.org/svn/

Cheers! 

Alex</description>
		<content:encoded><![CDATA[<p>I believe that my ActiveFixture can be utilized to solve this headache of yours (FYI: ActiveFixture reads the belongs_to tag in your models and do a graph-traversal to get the correct order of fixture insertions &#8212; this means that fixtures are loaded based on their foreign-key constraints thus always be in the correct insertion sequence ).  </p>
<p>The Preloaded Fixtures main call to the fixture can just be replaced by ActiveFixture.load_fixtures(), e.g.</p>
<p>module PreloadFixtures<br />
  def self.preload!<br />
    ActiveFixture.load_fixtures()<br />
  end<br />
&#8230;<br />
end</p>
<p>I&#8217;ll do some more research and see how ActiveFixture can be utilized better then just a rake task.  The current SVN to activefixture is at<br />
<a href="http://activefixture.rubyforge.org/svn/" rel="nofollow">http://activefixture.rubyforge.org/svn/</a></p>
<p>Cheers! </p>
<p>Alex</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jamie Flournoy</title>
		<link>http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/comment-page-1/#comment-1385</link>
		<dc:creator>Jamie Flournoy</dc:creator>
		<pubDate>Wed, 19 Sep 2007 17:19:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/#comment-1385</guid>
		<description>The following hack is what I used originally. Now I use the Preload Fixtures plugin instead, which loads all fixtures up front and also disables per-test fixture loading.

&lt;pre&gt;
# This code is taken from a comment in http://dev.rubyonrails.org/ticket/2404
# it makes the test fixtures get loaded once and only once, and removes the
# deletion-before-reloading-fixture-data step, so FKs never have a reason to
# complain. -JF
# neuter fixture deletions and multiple fixture insertions to work with database constraints
class Fixture
  attr_reader :class_name
end 
class Fixtures
    @@inserted_fixture_list = {}
    alias original_insert_fixtures insert_fixtures
    def insert_fixtures
        return if 0 == values.size
        return if values.size &gt; 0 &amp;&amp; @@inserted_fixture_list[values[0].class_name]
        @@inserted_fixture_list[values[0].class_name] = true
        class_name = values[0].class_name
        if class_name.respond_to? &quot;constantize&quot;
            table_name = values[0].class_name.constantize.table_name
        else
            table_name = values[0].class_name.table_name
        end
        unless ActiveRecord::Base.connection.select_one(&quot;select 1 from #{table_name}&quot;)
            original_insert_fixtures
        end
    end
    def delete_existing_fixtures() end
end
&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>The following hack is what I used originally. Now I use the Preload Fixtures plugin instead, which loads all fixtures up front and also disables per-test fixture loading.</p>
<pre>
# This code is taken from a comment in <a href="http://dev.rubyonrails.org/ticket/2404" rel="nofollow">http://dev.rubyonrails.org/ticket/2404</a>
# it makes the test fixtures get loaded once and only once, and removes the
# deletion-before-reloading-fixture-data step, so FKs never have a reason to
# complain. -JF
# neuter fixture deletions and multiple fixture insertions to work with database constraints
class Fixture
  attr_reader :class_name
end
class Fixtures
    @@inserted_fixture_list = {}
    alias original_insert_fixtures insert_fixtures
    def insert_fixtures
        return if 0 == values.size
        return if values.size > 0 &#038;&#038; @@inserted_fixture_list[values[0].class_name]
        @@inserted_fixture_list[values[0].class_name] = true
        class_name = values[0].class_name
        if class_name.respond_to? "constantize"
            table_name = values[0].class_name.constantize.table_name
        else
            table_name = values[0].class_name.table_name
        end
        unless ActiveRecord::Base.connection.select_one("select 1 from #{table_name}")
            original_insert_fixtures
        end
    end
    def delete_existing_fixtures() end
end
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sydney</title>
		<link>http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/comment-page-1/#comment-1322</link>
		<dc:creator>Sydney</dc:creator>
		<pubDate>Mon, 17 Sep 2007 01:36:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/#comment-1322</guid>
		<description>Could you post the hack you did to prevent fixture data being wiped out and reloaded for each test? 

Thanks - having the same headaches.</description>
		<content:encoded><![CDATA[<p>Could you post the hack you did to prevent fixture data being wiped out and reloaded for each test? </p>
<p>Thanks &#8211; having the same headaches.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pat Maddox</title>
		<link>http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/comment-page-1/#comment-338</link>
		<dc:creator>Pat Maddox</dc:creator>
		<pubDate>Mon, 06 Aug 2007 05:08:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.pervasivecode.com/blog/2007/08/02/rails-fixtures-the-test-db-and-testunit/#comment-338</guid>
		<description>This won&#039;t help you with the subsequent problems, but if you uncomment the

config.active_record.schema_format = :sql

line in config/environment.rb, rake will do a SQL schema dump instead of the Ruby-based schema.rb file.  This will include constraints, triggers, functions, etc.

I agree that Rails testing is a pain when it comes to having a non-retarded database.  Unfortunately that&#039;s the way it (currently) is and you just have to do some more work.

Fixtures especially are a PITA...you might be interested in &lt;a href=&quot;http://www.bofh.org.uk/articles/2007/08/05/doing-the-fixture-thing&quot; rel=&quot;nofollow&quot;&gt;doing fixtures without really doing fixtures&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>This won&#8217;t help you with the subsequent problems, but if you uncomment the</p>
<p>config.active_record.schema_format = :sql</p>
<p>line in config/environment.rb, rake will do a SQL schema dump instead of the Ruby-based schema.rb file.  This will include constraints, triggers, functions, etc.</p>
<p>I agree that Rails testing is a pain when it comes to having a non-retarded database.  Unfortunately that&#8217;s the way it (currently) is and you just have to do some more work.</p>
<p>Fixtures especially are a PITA&#8230;you might be interested in <a href="http://www.bofh.org.uk/articles/2007/08/05/doing-the-fixture-thing" rel="nofollow">doing fixtures without really doing fixtures</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
