I have been forced to make the switch from DM to AR for a project and
I'm migrating my rspec tests over. The first problem I faced was
having each spec wrapped in a transaction and rolled back after each
commit.

module Merb
  module Test
    module TransactionalSpecs
      def begin_transaction
        ActiveRecord::Base.connection.increment_open_transactions
        ActiveRecord::Base.connection.begin_db_transaction
      end

      def rollback_transaction
        #if Thread.current['open_transactions'] != 0
          ActiveRecord::Base.connection.rollback_db_transaction
          ActiveRecord::Base.connection.decrement_open_transactions
        #end
      end

      def self.included(base)
        base.before(:each) { begin_transaction }
        base.after(:each) { rollback_transaction }
      end
    end
  end
end

The problem I am facing now is resetting the id field, as even using
the transaction will make the id column increment each time. What is
the solution to this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to