Forum: RSpec before(:all)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
lawrence.pit (Guest)
on 2009-05-21 15:40
(Received via mailing list)
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
David C. (Guest)
on 2009-05-21 16:14
(Received via mailing list)
On Wed, May 20, 2009 at 10:27 PM, lawrence.pit 
<removed_email_address@domain.invalid>
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.
lawrence.pit (Guest)
on 2009-06-08 06:43
(Received via mailing list)
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
Kyle H. (Guest)
on 2009-06-09 18:11
(Received via mailing list)
On Sun, Jun 7, 2009 at 9:40 PM, 
lawrence.pit<removed_email_address@domain.invalid>
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
This topic is locked and can not be replied to.