lib/culerity/remote_browser_proxy.rb in culerity-0.2.12 vs lib/culerity/remote_browser_proxy.rb in culerity-0.2.13
- old
+ new
@@ -11,32 +11,36 @@
#
# Calls the block until it returns true or +time_to_wait+ is reached.
# +time_to_wait+ is 30 seconds by default
#
# Returns true upon success
- # Raises Timeout::Error when +time_to_wait+ is reached.
+ # Raises RuntimeError when +time_to_wait+ is reached.
#
def wait_until time_to_wait=30, &block
- Timeout.timeout(time_to_wait) do
- until block.call
- sleep 0.1
+ time_limit = Time.now + time_to_wait
+ until block.call
+ if Time.now > time_limit
+ raise "wait_until timeout after #{time_to_wait} seconds"
end
+ sleep 0.1
end
true
end
#
# Calls the block until it doesn't return true or +time_to_wait+ is reached.
# +time_to_wait+ is 30 seconds by default
#
# Returns true upon success
- # Raises Timeout::Error when +time_to_wait+ is reached.
+ # Raises RuntimeError when +time_to_wait+ is reached.
#
def wait_while time_to_wait=30, &block
- Timeout.timeout(time_to_wait) do
- while block.call
- sleep 0.1
+ time_limit = Time.now + time_to_wait
+ while block.call
+ if Time.now > time_limit
+ raise "wait_while timeout after #{time_to_wait} seconds"
end
+ sleep 0.1
end
true
end