[rspec-users] Test data problem (in general and with acts_as_tree)

Max Williams toastkid.williams at gmail.com
Tue Feb 26 08:39:37 EST 2008


I'm using before(:all) because i want to create a single 'family' of tree
objects and then run tests against it.  If i have all the object creation as
a before(:each) then the database will be even more full of duplications,
won't it?

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.  Do i need to explicitly tell the database to clear all the
records in an 'after' block?

On 26/02/2008, David Chelimsky <dchelimsky at gmail.com> wrote:
>
> On Tue, Feb 26, 2008 at 5:41 AM, Edvard Majakari <edvard at majakari.net>
> wrote:
> > > My problems seem to be arising from the fact that when i run the test,
> the
> >  > objects i created last time are still in the database.  Shouldn't
> they be
> >  > cleared out automatically?  This in turn is preventing me from saving
> root
> >
> >  I don't know RSpec that well, but I'd guess before(:all) is run only
> >  once in a describe block (and as such torn down only after the block
> >  is finished), whereas before(:each) is run before every example (and
> >  torn down respectively). So, I guess you'll want to use before(:each)
> >  version.
> >
> >  Was that it?
>
>
> Yep. Use before(:each) and all should be well.
>
> >
> >  --
>
> >  "One day, when he was naughty, Mr Bunnsy looked over the hedge into
> >  Farmer Fred's field and it was full of fresh green lettuces. Mr
> >  Bunnsy, however, was not full of lettuces. This did not seem fair."
> >   -- Terry Pratchett, Mr. Bunnsy Has An Adventure
> >  _______________________________________________
> >  rspec-users mailing list
> >  rspec-users at rubyforge.org
> >  http://rubyforge.org/mailman/listinfo/rspec-users
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080226/14103881/attachment.html 


More information about the rspec-users mailing list