lib/honeydew/device.rb in honeydew-0.17.0 vs lib/honeydew/device.rb in honeydew-0.18.0
- old
+ new
@@ -36,25 +36,13 @@
end
private
def perform_assertion action, arguments = {}, options = {}
- ensure_device_ready
-
- arguments[:timeout] = Honeydew.config.timeout.to_s
-
- debug "performing assertion #{action} with arguments #{arguments}"
- Timeout.timeout Honeydew.config.timeout.to_i, FinderTimeout do
- begin
- send_command action, arguments
- rescue ActionFailedError
- sleep 0.3
- retry
- end
- end
-
- rescue FinderTimeout
+ perform_action action, arguments, options
+ rescue ActionFailedError
+ false
end
def perform_action action, arguments = {}, options = {}
ensure_device_ready
arguments[:timeout] = Honeydew.config.timeout.to_s
@@ -74,40 +62,36 @@
end
case response
when Net::HTTPOK
true
- when Net::HTTPRequestedRangeNotSatisfiable
+ when Net::HTTPNoContent
raise ActionFailedError.new response.body
else
- raise "honeydew-server failed to process command, response: #{response.value}"
+ raise "honeydew-server failed to process command, response: #{response.body}"
end
end
def ensure_device_ready
@device_ready ||= begin
wait_for_honeydew_server
true
end
end
- def timeout_server_operation &block
- Timeout.timeout(Honeydew.config.server_timeout.to_i, ServerTimeoutError, &block)
- end
-
def wait_for_honeydew_server
info 'waiting for honeydew-server to respond'
- timeout_server_operation do
+ Timeout.timeout(Honeydew.config.server_timeout.to_i, ServerTimeoutError) do
sleep 0.1 until honeydew_server_alive?
end
info 'honeydew-server is alive and awaiting commands'
rescue ServerTimeoutError
raise 'timed out waiting for honeydew-server to respond'
end
def honeydew_server_alive?
- Net::HTTP.get_response(device_endpoint('/status')).code.to_i == 200
+ Net::HTTP.get_response(device_endpoint('/status')).is_a?(Net::HTTPSuccess)
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ENETRESET, EOFError
end
end
end