Nested database transactions to speed up the test suite

29 views
Skip to first unread message

Rodrigo Rosenfeld Rosas

unread,
Aug 7, 2016, 1:45:06 PM8/7/16
to rspec
Hi, maybe some of you might be interested in the approach I described in the following article [1] suggesting to use nested database transactions to speed up a test suite by creating common records in a before(:all) block rather than recreating them before every single test in the group. To make things simpler, I've also released the rspec_nested_transactions gem [2]. There are examples demonstrating how easy it is with both Sequel and ActiveRecord, provided your database supports either nested transactions or savepoints:



I hope it could be useful to some of you.

Thanks, Myron, for the idea to use Ruby Fibers to implement an around(:all)-like block in RSpec, a few years ago :) That was a really clever trick :)

Cheers,
Rodrigo.

Myron Marston

unread,
Aug 7, 2016, 6:21:09 PM8/7/16
to rs...@googlegroups.com
Cool!  Thanks for sharing, Rodrigo.

--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+unsubscribe@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/fcd8faf0-a9be-4ed0-b680-f38861feda6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rodrigo Rosenfeld Rosas

unread,
Aug 7, 2016, 6:22:16 PM8/7/16
to rs...@googlegroups.com

Thanks, Myron :-)


You received this message because you are subscribed to a topic in the Google Groups "rspec" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rspec/pEhg8naFn6M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rspec+unsubscribe@googlegroups.com.

To post to this group, send email to rs...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages