2016-08-06 13:15:15 -04:00
|
|
|
require "action_cable"
|
|
|
|
require "active_support/testing/autorun"
|
2015-01-15 12:28:02 -05:00
|
|
|
|
2016-08-06 13:15:15 -04:00
|
|
|
require "puma"
|
|
|
|
require "mocha/setup"
|
|
|
|
require "rack/mock"
|
2016-03-11 18:32:02 -05:00
|
|
|
|
|
|
|
begin
|
2016-08-06 13:15:15 -04:00
|
|
|
require "byebug"
|
2016-03-11 18:32:02 -05:00
|
|
|
rescue LoadError
|
|
|
|
end
|
2015-01-15 12:28:02 -05:00
|
|
|
|
2015-07-13 11:43:52 -04:00
|
|
|
# Require all the stubs and models
|
2017-05-15 10:17:28 -04:00
|
|
|
Dir[File.expand_path("stubs/*.rb", __dir__)].each { |file| require file }
|
2015-07-14 11:58:46 -04:00
|
|
|
|
2016-09-30 21:27:26 -04:00
|
|
|
class ActionCable::TestCase < ActiveSupport::TestCase
|
2016-01-27 23:55:31 -05:00
|
|
|
def wait_for_async
|
2016-04-15 02:04:42 -04:00
|
|
|
wait_for_executor Concurrent.global_io_executor
|
2015-10-15 22:11:49 -04:00
|
|
|
end
|
2016-01-24 05:43:40 -05:00
|
|
|
|
2016-01-27 23:55:31 -05:00
|
|
|
def run_in_eventmachine
|
|
|
|
yield
|
|
|
|
wait_for_async
|
2016-01-24 05:43:40 -05:00
|
|
|
end
|
2016-04-15 02:04:42 -04:00
|
|
|
|
|
|
|
def wait_for_executor(executor)
|
2016-09-19 05:29:23 -04:00
|
|
|
# do not wait forever, wait 2s
|
|
|
|
timeout = 2
|
2016-04-15 02:04:42 -04:00
|
|
|
until executor.completed_task_count == executor.scheduled_task_count
|
|
|
|
sleep 0.1
|
2016-09-19 05:29:23 -04:00
|
|
|
timeout -= 0.1
|
|
|
|
raise "Executor could not complete all tasks in 2 seconds" unless timeout > 0
|
2016-04-15 02:04:42 -04:00
|
|
|
end
|
|
|
|
end
|
2016-03-01 19:50:19 -05:00
|
|
|
end
|