I&#39;m using before(:all) because i want to create a single &#39;family&#39; of tree objects and then run tests against it.&nbsp; If i have all the object creation as a before(:each) then the database will be even more full of duplications, won&#39;t it?<br>
<br>My problem, though, is that the data is left over from the last time (in fact all previous times) that i ran the spec file, where i thought that it was cleared out.&nbsp; Do i need to explicitly tell the database to clear all the records in an &#39;after&#39; block?<br>
<br><div><span class="gmail_quote">On 26/02/2008, <b class="gmail_sendername">David Chelimsky</b> &lt;<a href="mailto:dchelimsky@gmail.com">dchelimsky@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Tue, Feb 26, 2008 at 5:41 AM, Edvard Majakari &lt;<a href="mailto:edvard@majakari.net">edvard@majakari.net</a>&gt; wrote:<br> &gt; &gt; My problems seem to be arising from the fact that when i run the test, the<br> &gt;&nbsp;&nbsp;&gt; objects i created last time are still in the database.&nbsp;&nbsp;Shouldn&#39;t they be<br>
 &gt;&nbsp;&nbsp;&gt; cleared out automatically?&nbsp;&nbsp;This in turn is preventing me from saving root<br> &gt;<br> &gt;&nbsp;&nbsp;I don&#39;t know RSpec that well, but I&#39;d guess before(:all) is run only<br> &gt;&nbsp;&nbsp;once in a describe block (and as such torn down only after the block<br>
 &gt;&nbsp;&nbsp;is finished), whereas before(:each) is run before every example (and<br> &gt;&nbsp;&nbsp;torn down respectively). So, I guess you&#39;ll want to use before(:each)<br> &gt;&nbsp;&nbsp;version.<br> &gt;<br> &gt;&nbsp;&nbsp;Was that it?<br> <br> <br>
Yep. Use before(:each) and all should be well.<br> <br> &gt;<br> &gt;&nbsp;&nbsp;--<br> <br>&gt;&nbsp;&nbsp;&quot;One day, when he was naughty, Mr Bunnsy looked over the hedge into<br> &gt;&nbsp;&nbsp;Farmer Fred&#39;s field and it was full of fresh green lettuces. Mr<br>
 &gt;&nbsp;&nbsp;Bunnsy, however, was not full of lettuces. This did not seem fair.&quot;<br> &gt;&nbsp;&nbsp; -- Terry Pratchett, Mr. Bunnsy Has An Adventure<br> &gt;&nbsp;&nbsp;_______________________________________________<br> &gt;&nbsp;&nbsp;rspec-users mailing list<br>
 &gt;&nbsp;&nbsp;<a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br> &gt;&nbsp;&nbsp;<a href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a><br> &gt;<br> _______________________________________________<br>
 rspec-users mailing list<br> <a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br> <a href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users</a><br>
 </blockquote></div><br>