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

David Chelimsky dchelimsky at gmail.com
Tue Feb 26 09:33:23 EST 2008


On Tue, Feb 26, 2008 at 8:31 AM, Max Williams
<toastkid.williams at gmail.com> wrote:
> hehe, tbh even if the documentation had been there i probably wouldn't have
> read it :)

Yeah but then I get to say RTFM. Right now, TFM doesn't exist :(

>
> thanks!
>
>
>
> On 26/02/2008, David Chelimsky <dchelimsky at gmail.com> wrote:
> > On Tue, Feb 26, 2008 at 8:08 AM, Max Williams
> >
> > <toastkid.williams at gmail.com> wrote:
> > >
> > >
> > >
> > > On 26/02/2008, David Chelimsky <dchelimsky at gmail.com> wrote:
> > > >
> > > > On Tue, Feb 26, 2008 at 7:39 AM, Max Williams
> > > > <toastkid.williams at gmail.com> wrote:
> > > >
> > > >
> > > >
> > > > This does not happen for you implicitly when you use before(:all)
> > > > because there is no mechanism for running a group of examples in a
> > > > transaction.
> > >
> > > ah...i see.  I didn't know about that last bit. :)
> >
> >
> > FYI: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/310
> >
> > Cheers,
> >
> > David
> >
> >
> > >
> > > > > 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?
> > > >
> > > >
> > > > Yes.  If you want to use before(:all) to set up data, you need to use
> > > > after(:all) to clean it up explicitly.
> > > >
> > > > Please beware that this approach is extremely error prone over time.
> > > > If you ever introduce a side effect (intentionally or accidentally)
> > > > that modifies the data, you're going to look at the spec, see the data
> > > > you're setting up and incorrectly think that that's the data every
> > > > example is using. It is much, much safer (and more sane) to use
> > > > before(:each) even though it may slow things down a bit.
> > >
> > > Gotcha.  Thanks!
> > >
> > > > HTH,
> > > >
> > > > David
> > > >
> > > >
> > > >
> > >
> > >
> >
> > > _______________________________________________
> > >  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
> >
>
>
> _______________________________________________
>  rspec-users mailing list
>  rspec-users at rubyforge.org
>  http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list