Sha256: 7fcb4a70f2defb63b8466045e4a3446fff5fdcccfef4545358e9176f48dc8803

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require 'rubygems'
gem     'minitest'
require 'active_record'
require 'minitest/autorun'

module MiniTestWithHooks
  class Unit < MiniTest::Unit
    def before_suites
    end

    def after_suites
    end

    def _run_suites(suites, type)
      begin
        before_suites
        super(suites, type)
      ensure
        after_suites
      end
    end
  end
end

module MiniTestWithActiveRecord
  class Unit < MiniTestWithHooks::Unit

    def before_suites
      super
      ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
      ActiveRecord::Migration.verbose = false
      
      @migration  = Class.new(ActiveRecord::Migration) do

        def change
          create_table :users, :force => true do |t|
            t.string     :roles_mask
          end
          create_table :user_without_roles, :force => true do |t|
            t.string     :roles_mask
          end
          create_table :user_without_role_masks, :force => true do |t|
          end
        end

      end
      
      @migration.new.migrate(:up)
    end

    def after_suites
      @migration.new.migrate(:down)
      super
    end
  end
end

MiniTest::Unit.runner = MiniTestWithActiveRecord::Unit.new

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
canard-0.2.0 test/test_helper.rb
canard-0.1.2 test/test_helper.rb
canard-0.1.1 test/test_helper.rb
canard-0.1.0 test/test_helper.rb