lib/soaspec/exchange_handlers/soap_handler.rb in soaspec-0.0.45 vs lib/soaspec/exchange_handlers/soap_handler.rb in soaspec-0.0.46

- old
+ new

@@ -117,11 +117,11 @@ def response_body(response, format: :hash) case format when :hash response.body when :raw - response.body.to_xml + response.xml else response.body end end @@ -146,34 +146,34 @@ def include_key?(response, expected) response.body.include_key? expected end # Returns the value at the provided xpath - # @param [Exchange] exchange + # @param [Savon::Response] response # @param [String] xpath # @return [String] Value inside element found through Xpath - def xpath_value_for(exchange: nil, xpath: nil) - raise ArgumentError unless exchange && xpath + def xpath_value_for(response: nil, xpath: nil) + raise ArgumentError unless response && xpath result = if Soaspec.strip_namespaces? && !xpath.include?(':') - temp_doc = exchange.response.doc + temp_doc = response.doc temp_doc.remove_namespaces! temp_doc.xpath(xpath).first else - exchange.response.xpath(xpath).first + response.xpath(xpath).first end - raise NoElementAtXpath, "No value at Xpath '#{xpath}'" unless result + raise NoElementAtPath, "No value at Xpath '#{xpath}'" unless result result.inner_text end # Based on a exchange, return the value at the provided xpath # If the path does not begin with a '/', a '//' is added to it - # @param [Exchange] exchange + # @param [Savon::Response] response # @param [String] path Xpath # @return [String] Value at Xpath - def value_from_path(exchange, path) + def value_from_path(response, path) path = '//' + path if path[0] != '/' - xpath_value_for(exchange: exchange, xpath: path) + xpath_value_for(response: response, xpath: path) end # Whether any of the keys of the Body Hash include value def include_value?(response, expected_value) response.body.include_value?(expected_value) \ No newline at end of file