lib/soaspec/exchange.rb in soaspec-0.0.46 vs lib/soaspec/exchange.rb in soaspec-0.0.47
- old
+ new
@@ -1,10 +1,11 @@
require_relative '../soaspec'
# This represents a request / response pair
class Exchange
+ # Class of Api Handler for which this exchange is made
attr_reader :api_class
# How many times to retry for a success
attr_accessor :retry_count
# Set retry for success variable to true so that request will be retried
@@ -21,11 +22,11 @@
# @param [Symbol, String] name Name shown in RSpec run
# @param [Hash] override_parameters Parameters to override for default params
def initialize(name, override_parameters = {})
@test_name = name.to_s
- @api_class = Soaspec.api_handler
+ @api_class = Soaspec.api_handler # This uses the global parameter. The handler should be set straight before an exchange is made
@override_parameters = override_parameters
@retry_for_success = false
self.retry_count = 3
end
@@ -35,10 +36,10 @@
def make_request
Soaspec::SpecLogger.add_to 'Example ' + @test_name
retry_count.times do
response = @api_class.make_request(@override_parameters)
return response unless retry_for_success?
- return response if @api_class.status_code_for(response) == 200
+ return response if (200..299).cover? @api_class.status_code_for(response)
response
end
end
# Stores a value in the api handler that can be accessed by the provided name
\ No newline at end of file