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?
This entry was posted on Monday, January 9th, 2012 at 8:23 pm and is filed under ruby. You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.