lib/soaspec/exchange/exchange.rb in soaspec-0.2.21 vs lib/soaspec/exchange/exchange.rb in soaspec-0.2.22

- old
+ new

@@ -64,16 +64,16 @@ # Will retry until success code reached if retry_for_success? is set # @return [Response] Response from Api handler def make_request Soaspec::SpecLogger.info 'Example ' + test_name request_params = @override_parameters - (1..retry_count).each do |count| + (0..retry_count).each do |count| response = exchange_handler.make_request(request_params) return response unless retry_for_success? return response if (200..299).cover? exchange_handler.status_code_for(response) - sleep 0.5 + sleep 0.5 # Time before retrying break response if count == retry_count end end # Name describing this class when used with `RSpec.describe` @@ -88,20 +88,24 @@ # @example For SOAP it will be a Savon response # response.body (body of response as Hash) # response.header (head of response as Hash) # @example For REST it will be a RestClient::Response def response + require 'forwardable' Soaspec.last_exchange = self @response ||= make_request @response.define_singleton_method(:exchange) { Soaspec.last_exchange } unless @response.respond_to?(:exchange) + @response.extend Forwardable + @response.delegate %i[value_from_path values_from_path] => :exchange @response end # @return [ResponseObject] Currently returning response object. This will change (in 0.3) to be itself to # allow easy method chaining def call if Soaspec.log_warnings - warn 'This method will be changed to return "Exchange" object in 0.3. Use "response" method if you want the response object' + warn 'This "call" method will be changed to return "Exchange" object in 0.3. ' \ + 'Use "response" method if you want the "response" object' end response end end