2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2018-12-19 14:47:15 +00:00
|
|
|
RSpec.configure do |config|
|
|
|
|
config.around(:each, type: :system) do |example|
|
|
|
|
|
|
|
|
server_required = example.metadata.fetch(:websocket, true)
|
|
|
|
|
|
|
|
if server_required
|
|
|
|
websocket_server = Thread.new do
|
|
|
|
WebsocketServer.run(
|
|
|
|
p: ENV['WS_PORT'] || 6042,
|
|
|
|
b: '0.0.0.0',
|
|
|
|
s: false,
|
|
|
|
v: false,
|
|
|
|
d: false,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
example.run
|
|
|
|
|
|
|
|
next if !server_required
|
|
|
|
|
2019-09-16 10:29:04 +00:00
|
|
|
# returns immediately and thread may be still shutting down
|
|
|
|
EventMachine.stop_event_loop
|
|
|
|
|
|
|
|
# give thread time to terminate
|
|
|
|
sleep 0.01 while websocket_server.status
|
2018-12-19 14:47:15 +00:00
|
|
|
end
|
|
|
|
end
|