Skip to content

Instantly share code, notes, and snippets.

@2rba
Created December 1, 2018 10:22
Show Gist options
  • Save 2rba/74d57775ac83ffcb0ff1da5eb5371212 to your computer and use it in GitHub Desktop.
Save 2rba/74d57775ac83ffcb0ff1da5eb5371212 to your computer and use it in GitHub Desktop.
Capybara 3.12.0 + Puma 3.10.0 + TimeCop Fix
module CoreExtensions
module Puma
module Reactor
def calculate_sleep
if @timeouts.empty?
@sleep_for = ::Puma::Reactor::DefaultSleepFor
else
diff = @timeouts.first.timeout_at.to_f - Time.now.to_f
if diff < 0.0
@sleep_for = 0
elsif diff > 60
@sleep_for = ::Puma::Reactor::DefaultSleepFor
else
@sleep_for = diff
end
end
end
end
end
end
# Fix Puma + TimeCop issue https://github.com/puma/puma/issues/1582
require 'puma/reactor'
Puma::Reactor.prepend CoreExtensions::Puma::Reactor
@cjlarose
Copy link

cjlarose commented Jan 2, 2020

Original issue described here: puma/puma#1582

This is no longer an issue in Puma 4.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment