[rspec-users] Examples not getting rolled back...

Tero Tilus tero at tilus.net
Wed Jan 7 09:11:48 EST 2009

I assume there's now something I'm totally missing here.  

I'm creating stuff in examples, just plain Foo.create, and the results
aren't getting rolled back.  I'm keep getting the following kind of
pattern in my logs

  ... log from example starts here ...
    SQL (0.0ms)   BEGIN
    SQL (0.0ms)   BEGIN
    ClassFoo Create (0.2ms)   INSERT ...
    Group Load (0.4ms)   SELECT ...
    Contains Create (0.2ms)   INSERT ...
  ... other stuff from example, no transaction stuff ...
    SQL (1.9ms)   COMMIT
    SQL (0.1ms)   ROLLBACK
  ... log from example ends here ...

all examples of the following form produce it

  describe ClassFoo do
    it "plim-ploms" do
      foo = ClassFoo.create

I'm just wondering if this is caused by those nested transactions.
MySQL (which I happen to use) doesn't support nested transactions and
is documented to just silently commit open transaction on new BEGIN.
Taken that I'd expect last ROLLBACK not to have any effect.

Where do those transactions come from?  I'd guess outer transaction
to be from RSpec and inner from ActiveRecord (oh, I'm on Rails).

And of course, what can I do about this...

A bit more stuff in pastie http://pastie.org/354521

Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/

More information about the rspec-users mailing list