module Maxitest::Threads

Public Instance Methods

maxitest_extra_threads() click to toggle source

if setup crashes we do not return anything to make the initial error visible

# File lib/maxitest/threads.rb, line 31
def maxitest_extra_threads
  @maxitest_threads_before ? Thread.list - @maxitest_threads_before : []
end
maxitest_kill_extra_threads() click to toggle source

also a helper methods for users

# File lib/maxitest/threads.rb, line 26
def maxitest_kill_extra_threads
  maxitest_extra_threads.map(&:kill).map(&:join)
end
maxitest_wait_for_extra_threads() click to toggle source

also a helper methods for users

# File lib/maxitest/threads.rb, line 21
def maxitest_wait_for_extra_threads
  sleep 0.01 while maxitest_extra_threads.any?
end
setup() click to toggle source
Calls superclass method
# File lib/maxitest/threads.rb, line 7
def setup
  @maxitest_threads_before = Thread.list
  super
end
teardown() click to toggle source
Calls superclass method
# File lib/maxitest/threads.rb, line 12
def teardown
  super
  found = maxitest_extra_threads
  raise "Test left #{found.size} extra threads (#{found})" if found.any?
ensure
  maxitest_kill_extra_threads
end