diff --git a/gems/aws-sdk-core/spec/aws/plugins/retry_errors_spec.rb b/gems/aws-sdk-core/spec/aws/plugins/retry_errors_spec.rb index 7ea64b65756..e911e43236d 100644 --- a/gems/aws-sdk-core/spec/aws/plugins/retry_errors_spec.rb +++ b/gems/aws-sdk-core/spec/aws/plugins/retry_errors_spec.rb @@ -312,11 +312,8 @@ module Plugins expect: { available_capacity: 10, retries: 2 } } ] - - # failure cases ending in success handle_with_retry(test_case_def) - # after success, new request test_case_post_success = [ { response: { status_code: 500, error: service_error }, @@ -327,10 +324,7 @@ module Plugins expect: { available_capacity: 10, retries: 1 } } ] - # reset request - config.max_attempts = 2 - resp.context.retries = 0 - resp.context.metadata[:retries] = {} + reset_request handle_with_retry(test_case_post_success) end diff --git a/gems/aws-sdk-core/spec/retry_errors_helper.rb b/gems/aws-sdk-core/spec/retry_errors_helper.rb index 302a7eff733..87b3120a633 100644 --- a/gems/aws-sdk-core/spec/retry_errors_helper.rb +++ b/gems/aws-sdk-core/spec/retry_errors_helper.rb @@ -40,7 +40,11 @@ def handle_with_retry(test_cases) apply_expectations(test_cases[i - 1]) end - +# Reset the request context for a subsequent call +def reset_request + resp.context.retries = 0 + resp.context.metadata[:retries] = {} +end # apply a delay to the current test case # See handle_with_retry for test case definition