retriable 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81c2ccf7c0dd361e1ca4f7eac29a8d988910a6c4
4
- data.tar.gz: bd45326dd3e4bbad1f93fd7127802ad443de127a
3
+ metadata.gz: 56415871220fd82fcfd72e2748a5a8283072bfa9
4
+ data.tar.gz: 93dfae047c70da13dc9b9a64331d1b1e62273ced
5
5
  SHA512:
6
- metadata.gz: a9b2ef78c9179a0eef716cdfc124a7b0ad325a65d8870d86311560f1f73dac3d055810998a9a0b74909163082508443efcda460cdee2e6c3316dd07885d2f589
7
- data.tar.gz: 5a18024b95eb0011b88b0ea3e25a374ca4c72e2d6f39fda027692d3b39a3da9f29b2d894fe9bbf214ff43f5a8ac803b4f266c92c09f4caf0e18a164fadad9402
6
+ metadata.gz: 42de39c02026a18aa580bac6186038460f1d83a48681b703da8fbe40bb1bcdd5a6f4e06d9cbc9daf5e2129d1e9f32c0cb05ce1f153de721e07341ed0f00dbb8c
7
+ data.tar.gz: 42dd35b52204d819e1b1d0c31eaadc5eef643b8a1daf69e694e29aff900d7995aa159ec2060bf4d414f66ffb2e5b6fd458ec2574a61d4192064cb0fc802a43e1
@@ -1,10 +1,14 @@
1
+ # Send builds to container-based infrastructure
2
+ # http://docs.travis-ci.com/user/workers/container-based-infrastructure/
3
+ sudo: false
1
4
  language: ruby
2
5
  rvm:
3
6
  - 1.9.3
4
7
  - 2.0.0
5
- - 2.1.5
6
- - 2.2.0
8
+ - 2.1.7
9
+ - 2.2.3
7
10
  - rbx
11
+ - jruby-9.0.0.0
8
12
  - ruby-head
9
13
  - jruby-head
10
14
 
@@ -13,6 +17,7 @@ matrix:
13
17
  - rvm: 1.9.3
14
18
  - rvm: ruby-head
15
19
  - rvm: jruby-head
20
+ - rvm: jruby-9.0.0.0
16
21
 
17
22
  addons:
18
23
  code_climate:
@@ -1,5 +1,10 @@
1
1
  ## HEAD
2
2
 
3
+ ## 2.1.0
4
+
5
+ * Fix bug #17 due to confusing the initial try as a retry.
6
+ * Switch to `Minitest` 5.6 expect syntax.
7
+
3
8
  ## 2.0.2
4
9
 
5
10
  * Change required_ruby_version in gemspec to >= 1.9.3.
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  group :test do
7
- gem "ruby_gntp"
7
+ # gem "ruby_gntp"
8
8
  gem "minitest-focus"
9
9
  gem "codeclimate-test-reporter", require: false
10
10
  gem "simplecov", require: false
data/README.md CHANGED
@@ -38,9 +38,9 @@ gem 'retriable', '~> 2.0'
38
38
 
39
39
  ## Usage
40
40
 
41
- Code in a `Retriable.retriable` block will be retried if an exception is raised. By default, Retriable will rescue any exception inherited from `StandardError`, make 3 retry tries before raising the last exception, and also use randomized exponential backoff to calculate each succeeding try interval. The default interval table with 10 tries looks like this (in seconds):
41
+ Code in a `Retriable.retriable` block will be retried if an exception is raised. By default, Retriable will rescue any exception inherited from `StandardError`, make 3 tries (including the initial attempt) before raising the last exception, and also use randomized exponential backoff to calculate each succeeding try interval. The default interval table with 10 tries looks like this (in seconds):
42
42
 
43
- | request# | retry interval | randomized interval |
43
+ | retry# | retry interval | randomized interval |
44
44
  | -------- | -------------- | ------------------------------- |
45
45
  | 1 | 0.5 | [0.25, 0.75] |
46
46
  | 2 | 0.75 | [0.375, 1.125] |
@@ -70,7 +70,7 @@ end
70
70
 
71
71
  Here are the available options:
72
72
 
73
- `tries` (default: 3) - Number of tries to make at running your code block.
73
+ `tries` (default: 3) - Number of attempts to make at running your code block (includes intial attempt).
74
74
 
75
75
  `base_interval` (default: 0.5) - The initial interval in seconds between tries.
76
76
 
@@ -88,7 +88,7 @@ randomized_interval = retry_interval * (random value in range [1 - randomization
88
88
 
89
89
  `intervals` (default: nil) - Skip generated intervals and provide your own array of intervals in seconds. Setting this option will ignore `tries`, `base_interval`, `max_interval`, `rand_factor`, and `multiplier` values.
90
90
 
91
- `timeout` (default: 0) - Number of seconds to allow the code block to run before raising a Timeout::Error
91
+ `timeout` (default: nil) - Number of seconds to allow the code block to run before raising a `Timeout::Error` inside each try. Default is `nil` means the code block can run forever without raising error.
92
92
 
93
93
  `on` (default: [StandardError]) - An `Array` of exceptions to rescue for each try, a `Hash` where the keys are `Exception` classes and the values can be a single `Regexp` pattern or a list of patterns, or a single `Exception` type.
94
94
 
@@ -161,6 +161,8 @@ Retriable.retriable intervals: [0.5, 1.0, 2.0, 2.5] do
161
161
  end
162
162
  ```
163
163
 
164
+ This example makes 5 total attempts, if the first attempt fails, the 2nd attempt occurs 0.5 seconds later.
165
+
164
166
  ### Turn off Exponential Backoff
165
167
 
166
168
  Exponential backoff is enabled by default, if you want to simply retry code every second, 5 times maximum, you can do this:
@@ -248,6 +250,15 @@ retriable do
248
250
  end
249
251
  ```
250
252
 
253
+ ## Proxy Wrapper Object
254
+
255
+ [@julik](https://github.com/julik) has created a gem called [retriable_proxy](https://github.com/julik/retriable_proxy) that extends `retriable` with the ability to wrap objects and specify which methods you want to be retriable, like so:
256
+
257
+ ```ruby
258
+ # api_endpoint is an instance of some kind of class that connects to an API
259
+ RetriableProxy.for_object(api_endpoint, on: Net::TimeoutError)
260
+ ```
261
+
251
262
  ## Credits
252
263
 
253
- The randomized exponetial backoff implementation was inspired by the one used in Google's [google-http-java-client](https://code.google.com/p/google-http-java-client/wiki/ExponentialBackoff) project.
264
+ The randomized exponential backoff implementation was inspired by the one used in Google's [google-http-java-client](https://code.google.com/p/google-http-java-client/wiki/ExponentialBackoff) project.
@@ -1,7 +1,7 @@
1
1
  require "timeout"
2
- require "retriable/config"
3
- require "retriable/exponential_backoff"
4
- require "retriable/version"
2
+ require_relative "retriable/config"
3
+ require_relative "retriable/exponential_backoff"
4
+ require_relative "retriable/version"
5
5
 
6
6
  module Retriable
7
7
  extend self
@@ -32,10 +32,10 @@ module Retriable
32
32
  elapsed_time = -> { Time.now - start_time }
33
33
 
34
34
  if intervals
35
- tries = intervals.size
35
+ tries = intervals.size + 1
36
36
  else
37
37
  intervals = ExponentialBackoff.new(
38
- tries: tries,
38
+ tries: tries - 1,
39
39
  base_interval: base_interval,
40
40
  multiplier: multiplier,
41
41
  max_interval: max_interval,
@@ -45,7 +45,8 @@ module Retriable
45
45
 
46
46
  exception_list = on.kind_of?(Hash) ? on.keys : on
47
47
 
48
- intervals.each.with_index(1) do |interval, try|
48
+ tries.times do |index|
49
+ try = index + 1
49
50
  begin
50
51
  if timeout
51
52
  Timeout::timeout(timeout) { return yield(try) }
@@ -65,6 +66,7 @@ module Retriable
65
66
  raise unless message_match
66
67
  end
67
68
 
69
+ interval = intervals[index]
68
70
  on_retry.call(exception, try, elapsed_time.call, interval) if on_retry
69
71
  raise if try >= tries || (elapsed_time.call + interval) > max_elapsed_time
70
72
  sleep interval if config.sleep_disabled != true
@@ -1,4 +1,4 @@
1
- require "retriable"
1
+ require_relative "../../retriable"
2
2
 
3
3
  module Kernel
4
4
  def retriable(opts = {}, &block)
@@ -1,3 +1,3 @@
1
1
  module Retriable
2
- VERSION = "2.0.2"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.7"
25
25
  spec.add_development_dependency "rake", "~> 10.4"
26
26
 
27
- spec.add_development_dependency "minitest", "~> 5.5"
27
+ spec.add_development_dependency "minitest", "~> 5.6"
28
28
  spec.add_development_dependency "guard"
29
29
  spec.add_development_dependency "guard-minitest"
30
30
  end
@@ -6,42 +6,42 @@ describe Retriable::Config do
6
6
  end
7
7
 
8
8
  it "sleep defaults to enabled" do
9
- subject.new.sleep_disabled.must_equal false
9
+ expect(subject.new.sleep_disabled).must_equal false
10
10
  end
11
11
 
12
12
  it "tries defaults to 3" do
13
- subject.new.tries.must_equal 3
13
+ expect(subject.new.tries).must_equal 3
14
14
  end
15
15
 
16
16
  it "max interval defaults to 60" do
17
- subject.new.max_interval.must_equal 60
17
+ expect(subject.new.max_interval).must_equal 60
18
18
  end
19
19
 
20
20
  it "randomization factor defaults to 0.5" do
21
- subject.new.base_interval.must_equal 0.5
21
+ expect(subject.new.base_interval).must_equal 0.5
22
22
  end
23
23
 
24
24
  it "multiplier defaults to 1.5" do
25
- subject.new.multiplier.must_equal 1.5
25
+ expect(subject.new.multiplier).must_equal 1.5
26
26
  end
27
27
 
28
28
  it "max elapsed time defaults to 900" do
29
- subject.new.max_elapsed_time.must_equal 900
29
+ expect(subject.new.max_elapsed_time).must_equal 900
30
30
  end
31
31
 
32
32
  it "intervals defaults to nil" do
33
- subject.new.intervals.must_be_nil
33
+ expect(subject.new.intervals).must_be_nil
34
34
  end
35
35
 
36
36
  it "timeout defaults to nil" do
37
- subject.new.timeout.must_be_nil
37
+ expect(subject.new.timeout).must_be_nil
38
38
  end
39
39
 
40
40
  it "on defaults to [StandardError]" do
41
- subject.new.on.must_equal [StandardError]
41
+ expect(subject.new.on).must_equal [StandardError]
42
42
  end
43
43
 
44
44
  it "on retry handler defaults to nil" do
45
- subject.new.on_retry.must_be_nil
45
+ expect(subject.new.on_retry).must_be_nil
46
46
  end
47
47
  end
@@ -10,23 +10,23 @@ describe Retriable::ExponentialBackoff do
10
10
  end
11
11
 
12
12
  it "tries defaults to 3" do
13
- subject.new.tries.must_equal 3
13
+ expect(subject.new.tries).must_equal 3
14
14
  end
15
15
 
16
16
  it "max interval defaults to 60" do
17
- subject.new.max_interval.must_equal 60
17
+ expect(subject.new.max_interval).must_equal 60
18
18
  end
19
19
 
20
20
  it "randomization factor defaults to 0.5" do
21
- subject.new.base_interval.must_equal 0.5
21
+ expect(subject.new.base_interval).must_equal 0.5
22
22
  end
23
23
 
24
24
  it "multiplier defaults to 1.5" do
25
- subject.new.multiplier.must_equal 1.5
25
+ expect(subject.new.multiplier).must_equal 1.5
26
26
  end
27
27
 
28
28
  it "generates 10 randomized intervals" do
29
- subject.new(tries: 9).intervals.must_equal([
29
+ expect(subject.new(tries: 9).intervals).must_equal([
30
30
  0.5244067512211441,
31
31
  0.9113920238761231,
32
32
  1.2406087918999114,
@@ -40,11 +40,11 @@ describe Retriable::ExponentialBackoff do
40
40
  end
41
41
 
42
42
  it "generates defined number of intervals" do
43
- subject.new(tries: 5).intervals.size.must_equal 5
43
+ expect(subject.new(tries: 5).intervals.size).must_equal 5
44
44
  end
45
45
 
46
46
  it "generates intervals with a defined base interval" do
47
- subject.new(base_interval: 1).intervals.must_equal([
47
+ expect(subject.new(base_interval: 1).intervals).must_equal([
48
48
  1.0488135024422882,
49
49
  1.8227840477522461,
50
50
  2.4812175837998227
@@ -52,7 +52,7 @@ describe Retriable::ExponentialBackoff do
52
52
  end
53
53
 
54
54
  it "generates intervals with a defined multiplier" do
55
- subject.new(multiplier: 1).intervals.must_equal([
55
+ expect(subject.new(multiplier: 1).intervals).must_equal([
56
56
  0.5244067512211441,
57
57
  0.607594682584082,
58
58
  0.5513816852888495
@@ -60,7 +60,7 @@ describe Retriable::ExponentialBackoff do
60
60
  end
61
61
 
62
62
  it "generates intervals with a defined max interval" do
63
- subject.new(max_interval: 1.0, rand_factor: 0.0).intervals.must_equal([
63
+ expect(subject.new(max_interval: 1.0, rand_factor: 0.0).intervals).must_equal([
64
64
  0.5,
65
65
  0.75,
66
66
  1.0
@@ -68,7 +68,7 @@ describe Retriable::ExponentialBackoff do
68
68
  end
69
69
 
70
70
  it "generates intervals with a defined rand_factor" do
71
- subject.new(rand_factor: 0.2).intervals.must_equal([
71
+ expect(subject.new(rand_factor: 0.2).intervals).must_equal([
72
72
  0.5097627004884576,
73
73
  0.8145568095504492,
74
74
  1.1712435167599646
@@ -76,10 +76,10 @@ describe Retriable::ExponentialBackoff do
76
76
  end
77
77
 
78
78
  it "generates 10 non-randomized intervals" do
79
- subject.new(
79
+ expect(subject.new(
80
80
  tries: 10,
81
81
  rand_factor: 0.0
82
- ).intervals.must_equal([
82
+ ).intervals).must_equal([
83
83
  0.5,
84
84
  0.75,
85
85
  1.125,
@@ -24,15 +24,15 @@ describe Retriable do
24
24
  tries += 1
25
25
  end
26
26
 
27
- tries.must_equal 1
27
+ expect(tries).must_equal 1
28
28
  end
29
29
 
30
30
  it "raises a LocalJumpError if #retriable is not given a block" do
31
- -> do
31
+ expect do
32
32
  subject.retriable on: StandardError
33
33
  end.must_raise LocalJumpError
34
34
 
35
- -> do
35
+ expect do
36
36
  subject.retriable on: StandardError, timeout: 2
37
37
  end.must_raise LocalJumpError
38
38
  end
@@ -40,58 +40,59 @@ describe Retriable do
40
40
  it "makes 3 tries when retrying block of code raising StandardError with no arguments" do
41
41
  tries = 0
42
42
 
43
- -> do
43
+ expect do
44
44
  subject.retriable do
45
45
  tries += 1
46
46
  raise StandardError.new
47
47
  end
48
48
  end.must_raise StandardError
49
49
 
50
- tries.must_equal 3
50
+ expect(tries).must_equal 3
51
51
  end
52
52
 
53
53
  it "makes only 1 try when exception raised is not ancestor of StandardError" do
54
54
  tries = 0
55
55
 
56
- -> do
56
+ expect do
57
57
  subject.retriable do
58
58
  tries += 1
59
59
  raise TestError.new
60
60
  end
61
61
  end.must_raise TestError
62
62
 
63
- tries.must_equal 1
63
+ expect(tries).must_equal 1
64
64
  end
65
65
 
66
66
  it "#retriable with custom exception tries 3 times and re-raises the exception" do
67
67
  tries = 0
68
- -> do
68
+
69
+ expect do
69
70
  subject.retriable on: TestError do
70
71
  tries += 1
71
72
  raise TestError.new
72
73
  end
73
74
  end.must_raise TestError
74
75
 
75
- tries.must_equal 3
76
+ expect(tries).must_equal 3
76
77
  end
77
78
 
78
79
  it "#retriable tries 10 times" do
79
80
  tries = 0
80
81
 
81
- -> do
82
+ expect do
82
83
  subject.retriable(
83
- tries: 10
84
+ tries: 10,
84
85
  ) do
85
- tries += 1
86
- raise StandardError.new
86
+ tries += 1
87
+ raise StandardError.new
87
88
  end
88
89
  end.must_raise StandardError
89
90
 
90
- tries.must_equal 10
91
+ expect(tries).must_equal 10
91
92
  end
92
93
 
93
94
  it "#retriable will timeout after 1 second" do
94
- -> do
95
+ expect do
95
96
  subject.retriable timeout: 1 do
96
97
  sleep 1.1
97
98
  end
@@ -99,26 +100,26 @@ describe Retriable do
99
100
  end
100
101
 
101
102
  it "applies a randomized exponential backoff to each try" do
102
- @tries = 0
103
- @time_table = []
103
+ tries = 0
104
+ time_table = []
104
105
 
105
106
  handler = ->(exception, try, elapsed_time, next_interval) do
106
- exception.class.must_equal ArgumentError
107
- @time_table << next_interval
107
+ expect(exception.class).must_equal ArgumentError
108
+ time_table << next_interval
108
109
  end
109
110
 
110
- -> do
111
+ expect do
111
112
  Retriable.retriable(
112
113
  on: [EOFError, ArgumentError],
113
114
  on_retry: handler,
114
- tries: 9
115
+ tries: 10,
115
116
  ) do
116
- @tries += 1
117
+ tries += 1
117
118
  raise ArgumentError.new
118
119
  end
119
120
  end.must_raise ArgumentError
120
121
 
121
- @time_table.must_equal([
122
+ expect(time_table).must_equal([
122
123
  0.5244067512211441,
123
124
  0.9113920238761231,
124
125
  1.2406087918999114,
@@ -127,18 +128,21 @@ describe Retriable do
127
128
  4.350816718580626,
128
129
  5.339852157217869,
129
130
  11.889873261212443,
130
- 18.756037881636484
131
+ 18.756037881636484,
132
+ nil,
131
133
  ])
134
+
135
+ expect(tries).must_equal(10)
132
136
  end
133
137
 
134
138
  describe "retries with an on_#retriable handler, 6 max retries, and a 0.0 rand_factor" do
135
139
  before do
136
140
  tries = 6
137
- @tries = 0
141
+ @try_count = 0
138
142
  @time_table = {}
139
143
 
140
144
  handler = ->(exception, try, elapsed_time, next_interval) do
141
- exception.class.must_equal ArgumentError
145
+ expect(exception.class).must_equal ArgumentError
142
146
  @time_table[try] = next_interval
143
147
  end
144
148
 
@@ -146,24 +150,24 @@ describe Retriable do
146
150
  on: [EOFError, ArgumentError],
147
151
  on_retry: handler,
148
152
  rand_factor: 0.0,
149
- tries: tries
153
+ tries: tries,
150
154
  ) do
151
- @tries += 1
152
- raise ArgumentError.new if @tries < tries
155
+ @try_count += 1
156
+ raise ArgumentError.new if @try_count < tries
153
157
  end
154
158
  end
155
159
 
156
160
  it "makes 6 tries" do
157
- @tries.must_equal 6
161
+ expect(@try_count).must_equal 6
158
162
  end
159
163
 
160
164
  it "applies a non-randomized exponential backoff to each try" do
161
- @time_table.must_equal({
165
+ expect(@time_table).must_equal({
162
166
  1 => 0.5,
163
167
  2 => 0.75,
164
168
  3 => 1.125,
165
169
  4 => 1.6875,
166
- 5 => 2.53125
170
+ 5 => 2.53125,
167
171
  })
168
172
  end
169
173
  end
@@ -176,25 +180,25 @@ describe Retriable do
176
180
  time_table[try] = next_interval
177
181
  end
178
182
 
179
- -> do
183
+ expect do
180
184
  subject.retriable(
181
185
  on: StandardError,
182
186
  on_retry: handler,
183
187
  rand_factor: 0.0,
184
188
  tries: 5,
185
- max_interval: 1.5
189
+ max_interval: 1.5,
186
190
  ) do
187
191
  tries += 1
188
192
  raise StandardError.new
189
193
  end
190
194
  end.must_raise StandardError
191
195
 
192
- time_table.must_equal({
196
+ expect(time_table).must_equal({
193
197
  1 => 0.5,
194
198
  2 => 0.75,
195
199
  3 => 1.125,
196
200
  4 => 1.5,
197
- 5 => 1.5
201
+ 5 => nil,
198
202
  })
199
203
  end
200
204
 
@@ -204,7 +208,7 @@ describe Retriable do
204
208
  0.75,
205
209
  1.125,
206
210
  1.5,
207
- 1.5
211
+ 1.5,
208
212
  ]
209
213
  time_table = {}
210
214
 
@@ -212,32 +216,38 @@ describe Retriable do
212
216
  time_table[try] = next_interval
213
217
  end
214
218
 
215
- -> do
219
+ try_count = 0
220
+
221
+ expect do
216
222
  subject.retriable(
217
223
  on_retry: handler,
218
- intervals: intervals
224
+ intervals: intervals,
219
225
  ) do
226
+ try_count += 1
220
227
  raise StandardError.new
221
228
  end
222
229
  end.must_raise StandardError
223
230
 
224
- time_table.must_equal({
231
+ expect(time_table).must_equal({
225
232
  1 => 0.5,
226
233
  2 => 0.75,
227
234
  3 => 1.125,
228
235
  4 => 1.5,
229
- 5 => 1.5
236
+ 5 => 1.5,
237
+ 6 => nil,
230
238
  })
239
+
240
+ expect(try_count).must_equal(6)
231
241
  end
232
242
 
233
243
  it "#retriable with a hash exception where the value is an exception message pattern" do
234
- e = -> do
244
+ e = expect do
235
245
  subject.retriable on: { TestError => /something went wrong/ } do
236
246
  raise TestError.new('something went wrong')
237
247
  end
238
248
  end.must_raise TestError
239
249
 
240
- e.message.must_equal "something went wrong"
250
+ expect(e.message).must_equal "something went wrong"
241
251
  end
242
252
 
243
253
  it "#retriable with a hash exception list where the values are exception message patterns" do
@@ -247,7 +257,7 @@ describe Retriable do
247
257
  exceptions[try] = exception
248
258
  end
249
259
 
250
- e = -> do
260
+ e = expect do
251
261
  subject.retriable tries: 4, on: { StandardError => nil, TestError => [/foo/, /bar/] }, on_retry: handler do
252
262
  tries += 1
253
263
  case tries
@@ -263,16 +273,16 @@ describe Retriable do
263
273
  end
264
274
  end.must_raise TestError
265
275
 
266
- e.message.must_equal "crash"
267
- exceptions[1].class.must_equal TestError
268
- exceptions[1].message.must_equal "foo"
269
- exceptions[2].class.must_equal TestError
270
- exceptions[2].message.must_equal "bar"
271
- exceptions[3].class.must_equal StandardError
276
+ expect(e.message).must_equal "crash"
277
+ expect(exceptions[1].class).must_equal TestError
278
+ expect(exceptions[1].message).must_equal "foo"
279
+ expect(exceptions[2].class).must_equal TestError
280
+ expect(exceptions[2].message).must_equal "bar"
281
+ expect(exceptions[3].class).must_equal StandardError
272
282
  end
273
283
 
274
284
  it "#retriable can be called in the global scope" do
275
- -> do
285
+ expect do
276
286
  retriable do
277
287
  puts "should raise NoMethodError"
278
288
  end
@@ -282,14 +292,14 @@ describe Retriable do
282
292
 
283
293
  tries = 0
284
294
 
285
- -> do
295
+ expect do
286
296
  retriable do
287
297
  tries += 1
288
298
  raise StandardError.new
289
299
  end
290
300
  end.must_raise StandardError
291
301
 
292
- tries.must_equal 3
302
+ expect(tries).must_equal 3
293
303
  end
294
304
  end
295
305
 
@@ -298,7 +308,7 @@ describe Retriable do
298
308
  c.sleep_disabled = false
299
309
  end
300
310
 
301
- subject.config.sleep_disabled.must_equal false
311
+ expect(subject.config.sleep_disabled).must_equal false
302
312
 
303
313
  tries = 0
304
314
  time_table = {}
@@ -307,19 +317,19 @@ describe Retriable do
307
317
  time_table[try] = elapsed_time
308
318
  end
309
319
 
310
- -> do
320
+ expect do
311
321
  subject.retriable(
312
322
  base_interval: 1.0,
313
323
  multiplier: 1.0,
314
324
  rand_factor: 0.0,
315
325
  max_elapsed_time: 2.0,
316
- on_retry: handler
326
+ on_retry: handler,
317
327
  ) do
318
328
  tries += 1
319
329
  raise EOFError.new
320
330
  end
321
331
  end.must_raise EOFError
322
332
 
323
- tries.must_equal 2
333
+ expect(tries).must_equal 2
324
334
  end
325
335
  end
@@ -7,7 +7,7 @@ build:
7
7
  steps:
8
8
  # Uncomment this to force RVM to use a specific Ruby version
9
9
  - rvm-use:
10
- version: 2.1.5
10
+ version: 2.2.3
11
11
 
12
12
  # A step that executes `bundle install` command
13
13
  - bundle-install
@@ -24,4 +24,4 @@ build:
24
24
  # Add more steps here:
25
25
  - script:
26
26
  name: rake
27
- code: bundle exec rake
27
+ code: bundle exec rake
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retriable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Chu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-31 00:00:00.000000000 Z
11
+ date: 2015-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.5'
47
+ version: '5.6'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.5'
54
+ version: '5.6'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 2.4.5
130
+ rubygems_version: 2.4.5.1
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Retriable is an simple DSL to retry failed code blocks with randomized exponential