module ActiveRecordExampleGroup
  extend ActiveSupport::Concern

  included do
    metadata[:type] = :active_record

    let(:rake) { Rake::Application.new }
    let(:task) { rake[self.class.description] }
    let(:namespace) { self.class.description.split(':').first }

    before(:all) do
      ActiveRecord::Base.establish_connection(
        :adapter => 'sqlite3',
        :database => ':memory:'
      )
    end
  end

  RSpec.configure do |config|
    config.include self, :example_group => { :file_path => /spec\/active_record/ }
  end
end

module ActiveRecordExampleGroup
  extend ActiveSupport::Concern

  included do
    metadata[:type] = :active_record

    let(:rake) { Rake::Application.new }
    let(:task) { rake[self.class.description] }
    let(:namespace) { self.class.description.split(':').first }

    before(:each) do
      ActiveRecord::Base.establish_connection(
        :adapter => 'sqlite3',
        :database => ':memory:'
      )
    end
  end

  RSpec.configure do |config|
    config.include self, :example_group => { :file_path => /spec\/active_record/ }
  end
end

Fix issue with database transactions in specs.
Fix issue with database transactions in specs.

It seems that since upgrading to Rails 3.1 and a newer version of the
sqlite3 gem that we need to reconnect to the database after each spec,
otherwise the DDL operations are no longer being reset properly.
