Before(:all)

Hi All,

When I execute database actions within a before(:each) they are rolled
back after each example test has run. I expected that if I execute db
actions within a before(:all) they would all be rolled back after all
examples finished running. This appears not to be the case, in my
case. Is there a way to get this behavior?

Cheers,
Lawrence

On Wed, May 20, 2009 at 10:27 PM, lawrence.pit [email protected]
wrote:

Hi All,

When I execute database actions within a before(:each) they are rolled
back after each example test has run. I expected that if I execute db
actions within a before(:all) they would all be rolled back after all
examples finished running. This appears not to be the case, in my
case. Is there a way to get this behavior?

Nothing built in, and it’s probably not something we’d support in
rspec-rails, which simply wraps the transaction handling provided by
rails, which rolls back after every test method (equivalent of an
rspec example).

You’re not the first to have asked for this, so having a solution for
it that would work with rails out of the box and with rspec would be
helpful to the community. But I think that would have to be in a
separate gem.

Hi,

I took a stab at this and created what I call Machinery. So far it
works great for me.

For those that are looking for a way to create objects in the database
in a before(:all) instead of a before(:each) to speed up tests, have a
look at:

http://github.com/lawrencepit/machinery

Cheers,
Lawrence

On Sun, Jun 7, 2009 at 9:40 PM, lawrence.pit[email protected]
wrote:

Hi,

I took a stab at this and created what I call Machinery. So far it
works great for me.

For those that are looking for a way to create objects in the database
in a before(:all) instead of a before(:each) to speed up tests, have a
look at:

http://github.com/lawrencepit/machinery

This plugin is awesome.

Thank you. =)

k