[rspec-users] Verifying some understanding about manipulating DB data in before/after callbacks in RSpec

Wes Gamble weyus at att.net
Thu Nov 6 16:32:42 EST 2008

We had an after(:each) callback that looked like this:

  PurchaseOrder.find(:all).each {|po| 
DraftInvoice.find_all_by_po_number(po.po_number).each {|di| di.destroy}}

which we were hoping would reset some purchase order data in a certain way.

However, because we have "self.use_transactional_fixtures = true" set in 
test_helper.rb, this code was never getting committed.

So, I just want to verify:

Attempting to manipulate data directly in the DB in a before/after 
callback doesn't make sense since those changes will not persist across 
tests because of the transactionality implied by 
"self.use_transactional_fixtures = true".  Is that correct?


More information about the rspec-users mailing list