Module: Maxitest::Threads
- Defined in:
- lib/maxitest/threads.rb
Instance Method Summary collapse
-
#maxitest_extra_threads ⇒ Object
if setup crashes we do not return anything to make the initial error visible.
-
#maxitest_kill_extra_threads ⇒ Object
also a helper methods for users.
-
#maxitest_wait_for_extra_threads ⇒ Object
also a helper methods for users.
- #setup ⇒ Object
- #teardown ⇒ Object
Instance Method Details
#maxitest_extra_threads ⇒ Object
if setup crashes we do not return anything to make the initial error visible
31 32 33 |
# File 'lib/maxitest/threads.rb', line 31 def maxitest_extra_threads @maxitest_threads_before ? Thread.list - @maxitest_threads_before : [] end |
#maxitest_kill_extra_threads ⇒ Object
also a helper methods for users
26 27 28 |
# 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 ⇒ Object
also a helper methods for users
21 22 23 |
# File 'lib/maxitest/threads.rb', line 21 def maxitest_wait_for_extra_threads sleep 0.01 while maxitest_extra_threads.any? end |
#setup ⇒ Object
7 8 9 10 |
# File 'lib/maxitest/threads.rb', line 7 def setup @maxitest_threads_before = Thread.list super end |
#teardown ⇒ Object
12 13 14 15 16 17 18 |
# 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 |