class ActionCable::TestCase

Public Instance Methods

run_in_eventmachine() { || ... } click to toggle source
# File actioncable/test/test_helper.rb, line 23
def run_in_eventmachine
  yield
  wait_for_async
end
wait_for_async() click to toggle source
# File actioncable/test/test_helper.rb, line 19
def wait_for_async
  wait_for_executor Concurrent.global_io_executor
end
wait_for_executor(executor) click to toggle source
# File actioncable/test/test_helper.rb, line 28
def wait_for_executor(executor)
  # do not wait forever, wait 2s
  timeout = 2
  until executor.completed_task_count == executor.scheduled_task_count
    sleep 0.1
    timeout -= 0.1
    raise "Executor could not complete all tasks in 2 seconds" unless timeout > 0
  end
end