lib/soaspec/exchange_handlers/exchange_handler.rb in soaspec-0.2.29 vs lib/soaspec/exchange_handlers/exchange_handler.rb in soaspec-0.2.30
- old
+ new
@@ -1,13 +1,20 @@
+# frozen_string_literal: true
+
require_relative 'handler_accessors'
+require_relative 'exchange_handler_defaults'
module Soaspec
# Inherit this for a class describing how to implement a particular exchange.
- # Has basic methods common for methods defining RSpec tests in YAML
+ # Has methods common to Soaspec framework for working with Exchange/Handler pair
class ExchangeHandler
extend Soaspec::HandlerAccessors
+ include ExchangeHandlerDefaults
+ # @return [Exception] Exception if raised
+ attr_accessor :exception
+
# Use an instance of this ExchangeHandler in any further Exchange's
# This is a convenience method as it creates an ExchangeHandler behind the scenes
# @return [ExchangeHandler] Exchange handler instance created
def self.use
new.use
@@ -62,36 +69,10 @@
def template_name=(name)
@request_option = :template
@template_name = name
end
- # Will be used in 'success_scenarios' shared examples.
- # Set though 'mandatory_elements' method
- # @return [Array] Array of symbols specifying element names
- def expected_mandatory_elements
- []
- end
-
- # Change this through 'mandatory_xpath_values' method to specify xpath results that must be present in the response
- # Will be used in 'success_scenarios' shared examples
- # @return [Hash] Hash of 'xpath' => 'expected value' pairs
- def expected_mandatory_xpath_values
- {}
- end
-
- # Change this through 'mandatory_json_values' method to specify json results that must be present in the response
- # Will be used in 'success_scenarios' shared examples
- # @return [Hash] Hash of 'json/path' => 'expected value' pairs
- def expected_mandatory_json_values
- {}
- end
-
- # @return [Boolean] Whether all xpaths will be done with XML that is converted to lower case
- def convert_to_lower?
- false
- end
-
# Stores a value in a method that can be accessed by the provided name
# @param [Symbol] name Name of method to use to access this value within handler
# @param [String] value Value to store
def store(name, value)
define_singleton_method('__stored_val__' + name.to_s) { value }
@@ -110,21 +91,8 @@
def set_remove_key(hash, key)
return unless hash.key? key
__send__("#{key}=", hash[key])
hash.delete key
- end
-
- # @return [Boolean] Whether to remove namespaces in xpath assertion automatically
- def strip_namespaces?
- false
- end
-
- # Request of API call. Either intended request or actual request
- # @param [Object] response Response from calling exchange
- def request(response)
- return "Request not yet sent Request option is #{@request_option}" unless response
-
- 'Specific API handler should implement this'
end
end
end