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

David Chelimsky dchelimsky at gmail.com
Wed Jan 7 14:08:44 EST 2009


On Wed, Jan 7, 2009 at 8:11 AM, Tero Tilus <tero at tilus.net> wrote:
> 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
>      ...
>    end
>    ...
>  end
>
> 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).

Is the app code opening transactions?

>
> 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/
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list