Sha256: 0d2507d94b1ad15395aff444745e17f9da9c6f7e26ad903323edd4fa1e3445cf

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

module Temporaries
  module Adapters
    class TestUnit < Base
      # This is used for both Test::Unit <= 1.9 and MiniTest::Unit
      # <= 1.9.2.
      def self.install(mod)
        mod::TestCase.class_eval do
          extend Extension
          include Values
          include Directory
        end
      end

      def before(&block)
        context.send(:include, self.module)
        context.befores << block
      end

      def after(&block)
        context.send(:include, self.module)
        context.afters << block
      end

      def module
        @module ||= Module.new do
          def self.included(base)
            base.extend self::ClassMethods
          end

          mod = Module.new do
            def befores
              @befores ||= []
            end

            def afters
              @afters ||= []
            end
          end
          const_set(:ClassMethods, mod)

          def setup
            self.class.befores.each{|proc| instance_eval(&proc)}
          end

          def teardown
            self.class.afters.each{|proc| instance_eval(&proc)}
          end
        end
      end

      module Extension
        def temporaries_adapter
          TestUnit.new(self)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
temporaries-0.2.0 lib/temporaries/adapters/test_unit.rb
temporaries-0.1.0 lib/temporaries/adapters/test_unit.rb