Sha256: 2ae3754261293d7fa8429684f2e6b542f78d50284cfb50e58bccfbd96664c3fe

Contents?: true

Size: 1.68 KB

Versions: 5

Compression:

Stored size: 1.68 KB

Contents

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
  class ExchangeHandler

    # Retrieve the name of the template file to be used in the API request
    attr_reader :template_name

    # Set instance variable name
    # @param [String, Symbol] name Name used when describing API test
    # @param [Hash] options Parameters defining handler. Used in descendants
    def initialize(name, options)
      @name = name
    end

    # Sets api handler variable globally. This is used in 'Exchange' class
    # @return [String] Name set upon initialisation
    def to_s
      Soaspec::Environment.api_handler = self
      @name.to_s
    end

    # Set the request option type and the template name
    # @param [String] name Name of file inside 'template' folder excluding extension
    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

    # Use this to set 'expected_mandatory_elements' see 'accessors'
    def mandatory_elements
      []
    end

    # Override this 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

    # Use this to set 'expected_mandatory_xpath_values' see 'accessors'
    def mandatory_xpath_values
      []
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
soaspec-0.0.35 lib/soaspec/exchange_handlers/exchange_handler.rb
soaspec-0.0.34 lib/soaspec/exchange_handlers/exchange_handler.rb
soaspec-0.0.33 lib/soaspec/exchange_handlers/exchange_handler.rb
soaspec-0.0.32 lib/soaspec/exchange_handlers/exchange_handler.rb
soaspec-0.0.31 lib/soaspec/exchange_handlers/exchange_handler.rb