Forum: Ruby on Rails testing a gem outside the rails framework

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
44a43e7fef8e933e802a7802b4bd3525?d=identicon&s=25 John Small (johnsmall)
on 2009-04-10 12:35
I'm writing an acts_as_something gem for ActiveRecord. I want to test it
only on the ActiveRecord part of the framework. Therefore I'm not
loading the entire rails framework, only ActiveRecord. That's all fine
but I need to wrap each test in a transaction which gets rolled back in
the teardown for each test. ActiveSupport is supposed to do this if you
set the undocumented use_transactional_fixtures = true except that
doesn't appear to be working in 2.3.3 and in any case I don't want to
load ActiveSupport.

Really I want to use Test::Unit along with Shoulda. I can get the
transaction to start in Test::Unit::TestCase setup, but how can I get it
to rollback in teardown? There's no rollback method to complement
ActiveRecord::Base.transaction

Comments please

John Small
This topic is locked and can not be replied to.