lib/soaspec/basic_soap_handler.rb in soaspec-0.0.9 vs lib/soaspec/basic_soap_handler.rb in soaspec-0.0.10

- old
+ new

@@ -1,18 +1,15 @@ require 'yaml' -require_relative 'common' require_relative 'tester' require_relative 'hash_methods' module Soaspec # Wraps around Savon client defining default values dependent on the soap request class BasicSoapHandler < Tester # Savon client used to make SOAP calls attr_accessor :client - # Namespaces used in XML body - attr_accessor :namespaces # SOAP Operation to use by default attr_accessor :operation # Options to log xml request and response def logging_options @@ -55,11 +52,10 @@ super options = default_options.merge logging_options options.merge! savon_options options.merge!(specific_options) @client = Savon.client(options) - self.namespaces = {} @name = name end def name(name) @test_values = {} @@ -89,14 +85,10 @@ def to_s Soaspec::Environment.api_handler = self # Sets this variable globally. This is used in 'Exchange' class @name end - def include?(value) - @xml_response.include? value - end - def default_hash=(hash) @request_option = :hash @default_hash = hash end @@ -119,9 +111,20 @@ end # Attributes set at the root XML element of SOAP request def root_attributes nil + end + + def xpath_value_for(param) + result = param[:exchange].response.xpath(param[:xpath]).first + raise 'No value at Xpath' unless result + result.inner_text + end + + def value_from_path(exchange, path) + path = '//' + path if path[0] != '/' + xpath_value_for(exchange: exchange, xpath: path) end end end \ No newline at end of file