Test ActiveRecord with Reset Transactions Without Rails

I found myself wanting to use Rails’ test transaction functionality in a Rails-less environment, and couldn’t find a tutorial about it. So I dug into the Rails source to figure out how it worked–just enough to pull it out into a gist. So, if you add this to your test_helper.rb or equivalent, you too can have your ActiveRecord tests wrapped in transactions that rollback after each case. It also lets you use fixtures, but who does that?

Comments are closed.