Sha256: 4ab6c5b84c1f5f1982aa204d3a90c18275907421be5ba1c7833fd23588a16b04

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

module Temporaries
  module Adapters
    class TestUnit < Base
      def self.install
        Test::Unit::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

3 entries across 3 versions & 1 rubygems

Version Path
temporaries-0.0.3 lib/temporaries/adapters/test_unit.rb
temporaries-0.0.2 lib/temporaries/adapters/test_unit.rb
temporaries-0.0.1 lib/temporaries/adapters/test_unit.rb