I have a set of examples that should run with a specific set of records in 
the database.

Since setting those records is an expensive operation I'd like to perform 
it just once per context.

For example:

context 'sample tree' do
    before(:all) { create_tree_records }
    
    example ...
end

The problem with this is that while before(:each) and the examples will run 
in a transaction that will be rolled back at the end of each example, that 
won't happen to the records created/modified by the before(:all) block.

It seems my database vendor (PostgreSQL) supports nested transactions 
(savepoints):

http://www.postgresql.org/about/

I should also notice that I'm using Sequel and it seems that transactions 
are reentrant in Sequel:

http://cheat.errtheblog.com/s/sequel/

Database#transaction is re-entrant:

  DB.transaction do # BEGIN issued only here
    DB.transaction
      dataset << {:first_name => 'Inigo', :last_name => 'Montoya'}
    end
end # COMMIT issued only here

So, this logic wouldn't work for me. I need a save point in a before(:all), 
so that I'd restore it on a before(:each).

Is there any recommendation to make this work in my specs?

Thanks in advance,
Rodrigo.

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rspec/-/VjmQQON6o1cJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rspec?hl=en.

Reply via email to