lib/soaspec/exchange.rb in soaspec-0.0.27 vs lib/soaspec/exchange.rb in soaspec-0.0.28
- old
+ new
@@ -19,25 +19,24 @@
# 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
- # Returns response object from Api
+ # Returns response object from Api. Will make the request if not made and then cache it for later on
# 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
+ @response ||= make_request
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)
+ @api_class.status_code_for(self.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
\ No newline at end of file