[rspec-users] Database clearing
mailing_lists at railsnewbie.com
Sat Sep 20 06:39:50 EDT 2008
On Sep 20, 2008, at 6:31 AM, Matt Wynne wrote:
> On 20 Sep 2008, at 01:59, Scott Taylor wrote:
>>> There's another approach though that I haven't tried yet. One of
>>> guys I work with truncates all the tables in the db before every
>>> example. He says this runs as fast or faster than transactional
>>> fixtures, and has the added benefit of NOT being in a transaction,
>>> means that if he actually DOES use a transaction in his
>>> application code
>>> then he can test it very easily. I've not tried it, but it seems
>>> like a
>>> cool idea.
> We have a few lines of code in our features steps/env.rb that does
> 1. patch AR to stash each AR object created in an array
> 2. in an After do block, call destroy on each of those objects.
> We can probably share if anyone would like to see this.
Seems like it would be more efficient to make sql calls to find the
tables, and then truncate each table.
More information about the rspec-users