lib/soaspec/exchange.rb in soaspec-0.0.19 vs lib/soaspec/exchange.rb in soaspec-0.0.20

- old
+ new

@@ -1,57 +1,57 @@ -require_relative '../soaspec' - -# This represents a request / response pair -class Exchange - - 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 - Soaspec::SpecLogger.add_to 'Example ' + @test_name - @response = make_request - @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 response object from Api - # For example for SOAP it will be a Savon response - # response.body (body of response as Hash) - # response.header (head of response as Hash) - def response - @response - end - - # Get status code from api class. This is http response for Web Api - # @return [Integer] Status code from api class - def status_code - @api_class.status_code_for(@response) - end - - # Extract value from path api class - # @param [String] path Path to return element for api class E.g - for SOAP this is XPath - # @return [String] Value at path - def [](path) - @api_class.value_from_path(self, path) - end - +require_relative '../soaspec' + +# This represents a request / response pair +class Exchange + + 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 + Soaspec::SpecLogger.add_to 'Example ' + @test_name + @response = make_request + @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 response object from Api + # For example for SOAP it will be a Savon response + # response.body (body of response as Hash) + # response.header (head of response as Hash) + def response + @response + end + + # Get status code from api class. This is http response for Web Api + # @return [Integer] Status code from api class + def status_code + @api_class.status_code_for(@response) + end + + # Extract value from path api class + # @param [String] path Path to return element for api class E.g - for SOAP this is XPath + # @return [String] Value at path + def [](path) + @api_class.value_from_path(self, path) + end + end \ No newline at end of file