@@ -23,7 +23,7 @@ def self.test_request
2323 it 'retries up to max_retries times' do
2424 allow ( test_module ) . to receive ( :client ) . and_return ( double ( 'client' ) )
2525 allow ( test_module . client ) . to receive ( :request ) do
26- double ( 'response' , code : '500' , body : '{"message": "Internal Server Error"}' )
26+ double ( 'response' , code : '500' , body : '{"message": "Internal Server Error"}' , '[]' : nil )
2727 end
2828
2929 expect ( test_module . client ) . to receive ( :request ) . exactly ( 4 ) . times
@@ -39,7 +39,7 @@ def self.test_request
3939 it 'retries on service unavailable' do
4040 allow ( test_module ) . to receive ( :client ) . and_return ( double ( 'client' ) )
4141 allow ( test_module . client ) . to receive ( :request ) do
42- double ( 'response' , code : '503' , body : '{"message": "Service Unavailable"}' )
42+ double ( 'response' , code : '503' , body : '{"message": "Service Unavailable"}' , '[]' : nil )
4343 end
4444
4545 expect ( test_module . client ) . to receive ( :request ) . exactly ( 4 ) . times
@@ -195,27 +195,27 @@ def self.test_request
195195 # Allow rand to return a consistent value for testing
196196 allow_any_instance_of ( Object ) . to receive ( :rand ) . and_return ( 0.5 )
197197
198- backoff_1 = test_module . send ( :calculate_backoff , 1 )
199- backoff_2 = test_module . send ( :calculate_backoff , 2 )
200- backoff_3 = test_module . send ( :calculate_backoff , 3 )
198+ backoff_attempt_1 = test_module . send ( :calculate_backoff , 1 )
199+ backoff_attempt_2 = test_module . send ( :calculate_backoff , 2 )
200+ backoff_attempt_3 = test_module . send ( :calculate_backoff , 3 )
201201
202202 # Attempt 1: base_delay * 2^0 = 1.0, jitter = 0.125
203- expect ( backoff_1 ) . to eq ( 1.125 )
203+ expect ( backoff_attempt_1 ) . to eq ( 1.125 )
204204
205205 # Attempt 2: base_delay * 2^1 = 2.0, jitter = 0.25
206- expect ( backoff_2 ) . to eq ( 2.25 )
206+ expect ( backoff_attempt_2 ) . to eq ( 2.25 )
207207
208208 # Attempt 3: base_delay * 2^2 = 4.0, jitter = 0.5
209- expect ( backoff_3 ) . to eq ( 4.5 )
209+ expect ( backoff_attempt_3 ) . to eq ( 4.5 )
210210 end
211211
212212 it 'respects max_delay' do
213213 allow_any_instance_of ( Object ) . to receive ( :rand ) . and_return ( 0.5 )
214214
215- backoff_10 = test_module . send ( :calculate_backoff , 10 )
215+ backoff_attempt_10 = test_module . send ( :calculate_backoff , 10 )
216216
217217 # Should cap at 30.0 + jitter (30.0 * 0.25 * 0.5 = 3.75)
218- expect ( backoff_10 ) . to eq ( 33.75 )
218+ expect ( backoff_attempt_10 ) . to eq ( 33.75 )
219219 end
220220 end
221221
@@ -225,7 +225,7 @@ def self.test_request
225225
226226 allow ( test_module ) . to receive ( :client ) . and_return ( double ( 'client' ) )
227227 allow ( test_module . client ) . to receive ( :request ) do
228- double ( 'response' , code : '500' , body : '{"message": "Internal Server Error"}' )
228+ double ( 'response' , code : '500' , body : '{"message": "Internal Server Error"}' , '[]' : nil )
229229 end
230230
231231 expect ( test_module . client ) . to receive ( :request ) . exactly ( 3 ) . times
@@ -243,7 +243,7 @@ def self.test_request
243243
244244 allow ( test_module ) . to receive ( :client ) . and_return ( double ( 'client' ) )
245245 allow ( test_module . client ) . to receive ( :request ) do
246- double ( 'response' , code : '500' , body : '{"message": "Internal Server Error"}' )
246+ double ( 'response' , code : '500' , body : '{"message": "Internal Server Error"}' , '[]' : nil )
247247 end
248248
249249 expect ( test_module . client ) . to receive ( :request ) . once
@@ -277,4 +277,3 @@ def self.test_request
277277 end
278278 end
279279end
280-
0 commit comments