fix: align CI RuboCop and e2e helpers

This commit is contained in:
Daniel Schädler 2026-05-06 12:39:12 +02:00
parent 8951070a15
commit 53cb6e38bd
3 changed files with 17 additions and 5 deletions

View File

@ -66,6 +66,11 @@ Rails/SkipsModelValidations:
- "app/services/tournament_sync_pusher.rb"
- "db/migrate/**/*"
Rails/Delegate:
Exclude:
- "app/controllers/tournaments_controller.rb"
- "e2e/lib/action_cable_client.rb"
Style/MultilineBlockChain:
Exclude:
- "e2e/lib/api_client.rb"

View File

@ -111,6 +111,7 @@ COPY script /app/script
COPY config.ru Rakefile /app/
COPY config/environments/production.rb /app/config/environments/beta.rb
COPY tasks.py /app/tasks.py
COPY .rubocop.yml /app/.rubocop.yml
COPY e2e /app/e2e
COPY lib /app/lib
COPY spec /app/spec

View File

@ -121,7 +121,9 @@ module TurniereE2E
websocket_url
end
delegate :write, to: :socket
def write(data)
socket.write(data)
end
private
@ -182,8 +184,8 @@ module TurniereE2E
end
def pump_until_open!(timeout: 10)
deadline = Time.zone.now + timeout
while Time.zone.now < deadline
deadline = monotonic_deadline(timeout)
while Process.clock_gettime(Process::CLOCK_MONOTONIC) < deadline
read_from_socket(timeout: 0.5)
return if driver.ready_state == 1
end
@ -192,14 +194,14 @@ module TurniereE2E
end
def wait_for!(timeout: 20)
deadline = Time.zone.now + timeout
deadline = monotonic_deadline(timeout)
loop do
until @messages.empty?
message = @messages.pop(true)
return message if yield(message)
end
raise "websocket message not received within #{timeout}s" if Time.zone.now >= deadline
raise "websocket message not received within #{timeout}s" if Process.clock_gettime(Process::CLOCK_MONOTONIC) >= deadline
read_from_socket(timeout: 0.5)
rescue ThreadError
@ -207,6 +209,10 @@ module TurniereE2E
end
end
def monotonic_deadline(timeout)
Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout
end
def read_from_socket(timeout:)
readable, = IO.select([socket], nil, nil, timeout)
return if readable.nil?