Module: EventMachine::Ventually

Defined in:
lib/em-ventually.rb,
lib/em-ventually/pool.rb,
lib/em-ventually/emify.rb,
lib/em-ventually/version.rb,
lib/em-ventually/eventually.rb,
lib/em-ventually/eventually/rspec.rb,
lib/em-ventually/eventually/minitest.rb,
lib/em-ventually/eventually/testunit.rb

Defined Under Namespace

Modules: Emify Classes: Eventually, Pool

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.every_defaultObject



15
16
17
# File 'lib/em-ventually.rb', line 15

def self.every_default
  instance_variable_defined?(:@every_default) ? @every_default : 0.1
end

.every_default=(value) ⇒ Object



11
12
13
# File 'lib/em-ventually.rb', line 11

def self.every_default=(value)
  @every_default = value
end

.included(o) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/em-ventually.rb', line 56

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?(:name) && o.name.to_s == 'RSpec::Core::ExampleGroup') || (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

.total_defaultObject



23
24
25
# File 'lib/em-ventually.rb', line 23

def self.total_default
  instance_variable_defined?(:@total_default) ? @total_default : 1.0
end

.total_default=(value) ⇒ Object



19
20
21
# File 'lib/em-ventually.rb', line 19

def self.total_default=(value)
  @total_default = value
end

Instance Method Details

#_poolObject



27
28
29
# File 'lib/em-ventually.rb', line 27

def _pool
  @_pool ||= Pool.new
end

#eventually(expectation = nil, opts = nil, &block) ⇒ Object Also known as: ly



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/em-ventually.rb', line 31

def eventually(expectation = nil, 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

#manually_stop_em!Object



46
47
48
# File 'lib/em-ventually.rb', line 46

def manually_stop_em!
  @_manually_stop_em = true
end

#parallel(&blk) ⇒ Object



50
51
52
53
54
# File 'lib/em-ventually.rb', line 50

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