aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/library/socket/fixtures/classes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/socket/fixtures/classes.rb')
-rw-r--r--spec/ruby/library/socket/fixtures/classes.rb21
1 files changed, 4 insertions, 17 deletions
diff --git a/spec/ruby/library/socket/fixtures/classes.rb b/spec/ruby/library/socket/fixtures/classes.rb
index 4cfa084333..6cc7ecb389 100644
--- a/spec/ruby/library/socket/fixtures/classes.rb
+++ b/spec/ruby/library/socket/fixtures/classes.rb
@@ -72,24 +72,11 @@ module SocketSpecs
end
def self.loop_with_timeout(timeout = TIME_TOLERANCE)
- require 'timeout'
- time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
- loop do
- if Process.clock_gettime(Process::CLOCK_MONOTONIC) - time >= timeout
- raise TimeoutError, "Did not succeed within #{timeout} seconds"
- end
-
- sleep 0.01 # necessary on OSX; don't know why
- yield
- end
- end
-
- def self.wait_until_success(timeout = TIME_TOLERANCE)
- loop_with_timeout(timeout) do
- begin
- return yield
- rescue
+ while yield == :retry
+ if Process.clock_gettime(Process::CLOCK_MONOTONIC) - start >= timeout
+ raise RuntimeError, "Did not succeed within #{timeout} seconds"
end
end
end