lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.3.1 vs lib/soaspec/exchange_handlers/rest_handler.rb in soaspec-0.3.2
- old
+ new
@@ -191,11 +191,11 @@
# @param [String] xpath Path to find elements from
# @param [String] attribute Attribute to find path for
# @return [Enumerable] Value inside element found through Xpath
def xpath_elements_for(response: nil, xpath: nil, attribute: nil)
raise ArgumentError unless response && xpath
- raise "Can't perform XPATH if response is not XML" unless Interpreter.response_type_for(response) == :xml
+ raise "Can't perform XPATH if response is not XML" unless %i[xml html].include? Interpreter.response_type_for(response)
xpath = prefix_xpath(xpath, attribute)
temp_doc = Nokogiri.parse(response.body).dup
if strip_namespaces? && !xpath.include?(':')
temp_doc.remove_namespaces!
@@ -237,10 +237,10 @@
# @param [String] attribute Generic attribute to find. Will override path
# @return [String] Value at Xpath
def value_from_path(response, path, attribute: nil)
path = path.to_s
case Interpreter.response_type_for(response)
- when :xml
+ when :xml, :html
result = xpath_elements_for(response: response, xpath: path, attribute: attribute).first
raise NoElementAtPath, "No value at Xpath '#{prefix_xpath(path, attribute)}' in '#{response.body}'" unless result
return result.inner_text if attribute.nil?
return result.attributes[attribute].inner_text