lib/honeydew/device.rb in honeydew-0.19.0 vs lib/honeydew/device.rb in honeydew-0.20.0

- old
+ new

@@ -9,12 +9,11 @@ include Honeydew::DeviceActions include Honeydew::DeviceMatchers include Honeydew::DeviceLogFormatter ServerTimeoutError = Class.new(Timeout::Error) - ActionFailedError = Class.new(Timeout::Error) - FinderTimeout = Class.new(Timeout::Error) + ActionFailedError = Class.new(RuntimeError) attr_reader :serial, :port def initialize(serial) @serial = serial @@ -57,32 +56,33 @@ request.set_form_data action: action, arguments: arguments.to_json.to_s response = benchmark do Net::HTTP.start(uri.hostname, uri.port) do |http| http.read_timeout = Honeydew.config.server_timeout - http.request request + response = http.request request + {response: response, action: action} end end case response when Net::HTTPOK info "action succeeded, response: #{response.body}" response.body when Net::HTTPNoContent info "action failed, response: #{response.body}" - raise ActionFailedError.new response.body + raise ActionFailedError.new "Action #{action} called with arguments #{arguments.inspect} failed" else raise "honeydew-server failed to process command, response: #{response.body}" end end def benchmark result = nil realtime = Benchmark.realtime do result = yield end - debug "action completed in #{(realtime * 1000).to_i}ms" - result + debug "action '#{result[:action]}' completed in #{(realtime * 1000).to_i}ms" + result[:response] end def ensure_device_ready @device_ready ||= begin wait_for_honeydew_server