spec/retriable_spec.rb in retriable-2.0.0.beta4 vs spec/retriable_spec.rb in retriable-2.0.0.beta5

- old
+ new

@@ -54,15 +54,15 @@ raise TestError.new end end.must_raise TestError end - it "#retriable with 10 max tries" do + it "#retriable tries 10 times" do attempts = 0 subject.retriable( - max_tries: 10 + tries: 10 ) do attempts += 1 raise EOFError.new if attempts < 10 end @@ -89,11 +89,11 @@ -> do Retriable.retriable( on: [EOFError, ArgumentError], on_retry: handler, rand_factor: 0.0, - max_tries: 9 + tries: 9 ) do @attempts += 1 raise ArgumentError.new end end.must_raise ArgumentError @@ -109,11 +109,11 @@ @time_table[9].between?(6.403, 19.210).must_equal true end describe "retries with an on_#retriable handler, 6 max retries, and a 0.0 rand_factor" do before do - max_tries = 6 + tries = 6 @attempts = 0 @time_table = {} handler = ->(exception, attempt, elapsed_time, next_interval) do exception.class.must_equal ArgumentError @@ -122,14 +122,14 @@ Retriable.retriable( on: [EOFError, ArgumentError], on_retry: handler, rand_factor: 0.0, - max_tries: max_tries + tries: tries ) do @attempts += 1 - raise ArgumentError.new if @attempts < max_tries + raise ArgumentError.new if @attempts < tries end end it "makes 6 attempts" do @attempts.must_equal 6 @@ -145,11 +145,11 @@ }) end end it "#retriable has a max interval of 1.5 seconds" do - max_tries = 6 + tries = 6 attempts = 0 time_table = {} handler = ->(exception, attempt, elapsed_time, next_interval) do time_table[attempt] = next_interval @@ -157,15 +157,15 @@ subject.retriable( on: EOFError, on_retry: handler, rand_factor: 0.0, - max_tries: max_tries, + tries: tries, max_interval: 1.5 ) do attempts += 1 - raise EOFError.new if attempts < max_tries + raise EOFError.new if attempts < tries end time_table.must_equal({ 1 => 0.5, 2 => 0.75, @@ -224,10 +224,10 @@ handler = ->(exception, attempt, elapsed_time, next_interval) do tries[attempt] = exception end e = -> do - subject.retriable max_tries: 4, on: { EOFError => nil, TestError => [/foo/, /bar/] }, on_retry: handler do + subject.retriable tries: 4, on: { EOFError => nil, TestError => [/foo/, /bar/] }, on_retry: handler do attempts += 1 case attempts when 1 raise TestError.new('foo') when 2