Sha256: 590582bddec3219ad1e3403e59a60177323bc687baabe03cb91e1fa84894feeb

Contents?: true

Size: 806 Bytes

Versions: 7

Compression:

Stored size: 806 Bytes

Contents

require "test/unit"
require 'spec'

if Mack.env == "test"
  module Mack
    module Testing # :nodoc: 
    end
  end

  # Wrap it so we don't accidentally alias the run method n times and run out of db connections!
  unless Mack::Testing.const_defined?("AR_TEST_EXTENSIONS")
    
    module Mack
      module Testing
        AR_TEST_EXTENSIONS = 1
        
        def rollback_transaction
          begin
            ActiveRecord::Base.transaction do
              yield if block_given?
              raise "Rollback!"
            end
          rescue => ex
            # we need to do this so we can throw up actual errors!
            unless ex.to_s == "Rollback!"
              raise ex
            end
          end
        end # rollback_transaction

      end # Testing
    end # Mack
  
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mack-active_record-0.8.0.1 lib/mack-active_record/test_extensions.rb
mack-active_record-0.8.0.2 lib/mack-active_record/test_extensions.rb
mack-active_record-0.8.1 lib/mack-active_record/test_extensions.rb
mack-active_record-0.8.0 lib/mack-active_record/test_extensions.rb
mack-active_record-0.8.0.101 lib/mack-active_record/test_extensions.rb
mack-active_record-0.8.0.3 lib/mack-active_record/test_extensions.rb
mack-active_record-0.8.2 lib/mack-active_record/test_extensions.rb