[rspec-users] Rollbacks, Sqlite3 bug

David Chelimsky dchelimsky at gmail.com
Thu Oct 25 00:40:46 EDT 2007

On 10/24/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:
> Okay - so the sqlite bug reported a day or so ago on the list is real
> bug.  I'm going to file something in the tracker for that...
> I also learned that before(:all)...after(:all) is not wrapped in a
> transaction, the way before(:each)...after(:each) is.  Is there some
> reason behind this?  Can you not wrap transactions inside transactions?

Only for DBs that support it. And it would add quite a bit of
complexity to rspec I think.

This is not really the intent of before(:all). It is more akin to
TestCaseSetup in xUnit - i.e. a class level method that doesn't share
state w/ the examples. So you might have some load script to get the
DB into a known state before(:all), and then run each example in a
transaction so it rolls back to that known state. I *think* that's how
rails does it but I'd have to peruse the code to verify that.

Accessing fixtures in before(:all) is something you can't do right now
because before(:all) is not running in the same scope as the examples
are - in fact, it runs before fixtures are loaded. Even if we changed
that, you still wouldn't want to access them before each, because
you'd be keeping a handle on objects whose underlying data are getting
rolled back after each example. Talk about unexpected

More information about the rspec-users mailing list