Sha256: c93a4cba8e7c6072ce11ba414755ea5413350b56cd6ceeaadd61b7f44ac7d900

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'set'
require 'eventmachine'
require 'callsite'
require 'em-ventually/version'
require 'em-ventually/eventually'
require 'em-ventually/pool'

module EventMachine
  module Ventually
    def _pool
      @_pool ||= Pool.new
    end

    def eventually(expectation = true, opts = nil, &block)
      ancestors = self.class.ancestors.map{|s| s.to_s}
      cls = if ancestors.include?('MiniTest::Unit::TestCase')
        Eventually::MiniTest
      elsif ancestors.include?('Test::Unit::TestCase')
        Eventually::TestUnit
      elsif self.class.to_s[/^RSpec::Core/]
        Eventually::RSpec
      else
        nil
      end
      cls.new(_pool, self, Callsite.parse(caller.first), expectation, opts, block)
    end

    def parallel(&blk)
      _pool.in_parallel do
        instance_eval(&blk)
      end
    end

    def self.included(o)
      ancestors = o.ancestors.map{|s| s.to_s}
      cls = if ancestors.include?('MiniTest::Unit::TestCase')
        Eventually::MiniTest
      elsif ancestors.include?('Test::Unit::TestCase')
        Eventually::TestUnit
      elsif o.respond_to?(:superclass) && o.superclass.to_s == 'RSpec::Core::ExampleGroup'
        Eventually::RSpec
      else
        raise("I know what testsuite i'm in!")
      end
      cls.inject
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
em-ventually-0.0.1 lib/em-ventually.rb