30 lines
698 B
Ruby
30 lines
698 B
Ruby
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
|
|
|
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
|
|
|
|
# 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
|
|
end
|
|
end
|