Sha256: fc2dc8ff1ee8f65bf35e2f03ed71c38c7c87032356c1ff8206d4f8a0ee46f6e9

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require_relative '../soaspec'

# This represents a request / response pair
class Exchange

  attr_reader :xml_response

  attr_reader :xml_doc

  def initialize(name, override_parameters = {})
    @test_name = name.to_s
    @api_class = Soaspec::Environment.api_handler
    @override_parameters = override_parameters
  end

  # Make request to handler with parameters defined
  def make_request
    @api_class.make_request(@override_parameters)
  end

  # Name describing this class when used with `RSpec.describe`
  # This will make the request and store the response
  # @return [String] Name given when initializing
  def to_s
    @response = make_request
    if @api_class.class < Soaspec::BasicSoapHandler
      @xml_response = @response.to_xml
      @xml_doc = @response.doc
    end
    @test_name
  end

  # Elements a shared 'success scenario' is expected to have
  def mandatory_elements
    @api_class.mandatory_elements
  end

  # Elements a shared 'success scenario' is expected to have
  def mandatory_xpath_values
    @api_class.mandatory_xpath_values
  end

  # Returns Savon response
  # response.body (body of response as Hash)
  # response.header (head of response as Hash)
  def response
    @response
  end

  def status_code
    @api_class.status_code_for(@response)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
soaspec-0.0.9 lib/soaspec/exchange.rb