attempt_this 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/Gemfile.lock +6 -11
- data/attempt_this.gemspec +14 -14
- data/lib/attempt_this/attempt_object.rb +54 -24
- data/spec/attempt_spec.rb +47 -47
- data/spec/scenarios_spec.rb +7 -11
- data/spec/spec_helper.rb +1 -2
- metadata +24 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa826f48090801a88909e9e8c6dc318efd26c95b
|
4
|
+
data.tar.gz: 2a781b4b14bf8156258a71a0b6742ed876463cda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6a9860fd483413ca05d4cb0b95e6816dc3d7f77474920ff260b014372d41999e5ffaa6ebbdcf9ec62d857e6148a4ec398af48bf918aae03f9e498287d86bab2
|
7
|
+
data.tar.gz: d2d28cfc7ff30dfdd300ec4b36c2ce68530ea61118f92ceebe32f29827c1ad297a7aca2d892837e0d846aff0cf0c03c917c56b72f80150e9a58c2cc8af39e11c
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
attempt_this (1.0.
|
4
|
+
attempt_this (1.0.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
9
|
diff-lcs (1.2.4)
|
10
10
|
docile (1.1.2)
|
11
|
-
macaddr (1.6.1)
|
12
|
-
systemu (~> 2.5.0)
|
13
11
|
multi_json (1.8.4)
|
14
12
|
rake (10.1.1)
|
15
13
|
rspec (2.13.0)
|
@@ -25,18 +23,15 @@ GEM
|
|
25
23
|
multi_json
|
26
24
|
simplecov-html (~> 0.8.0)
|
27
25
|
simplecov-html (0.8.0)
|
28
|
-
systemu (2.5.2)
|
29
|
-
uuid (2.3.7)
|
30
|
-
macaddr (~> 1.0)
|
31
26
|
|
32
27
|
PLATFORMS
|
28
|
+
java
|
33
29
|
ruby
|
34
30
|
x86-mingw32
|
35
31
|
|
36
32
|
DEPENDENCIES
|
37
33
|
attempt_this!
|
38
|
-
bundler
|
39
|
-
rake
|
40
|
-
rspec
|
41
|
-
simplecov
|
42
|
-
uuid
|
34
|
+
bundler (~> 1.6)
|
35
|
+
rake (~> 10.1)
|
36
|
+
rspec (~> 2.13)
|
37
|
+
simplecov (~> 0.8)
|
data/attempt_this.gemspec
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
|
-
s.name
|
3
|
-
s.version
|
4
|
-
s.date
|
5
|
-
s.summary
|
6
|
-
s.description
|
2
|
+
s.name = 'attempt_this'
|
3
|
+
s.version = '1.0.1'
|
4
|
+
s.date = '2014-04-29'
|
5
|
+
s.summary = 'Retry policy mix-in'
|
6
|
+
s.description = <<EOM
|
7
7
|
Retry policy mix-in with configurable number of attempts, delays, exception filters, and fall back strategies.
|
8
8
|
|
9
9
|
See project's home page for usage examples and more information.
|
10
10
|
EOM
|
11
|
-
s.authors
|
12
|
-
s.email
|
13
|
-
s.files
|
14
|
-
s.homepage
|
11
|
+
s.authors = ['Aliaksei Baturytski']
|
12
|
+
s.email = 'abaturytski@gmail.com'
|
13
|
+
s.files = `git ls-files`.split($/)
|
14
|
+
s.homepage = 'https://github.com/aliakb/attempt_this'
|
15
15
|
s.license = 'MIT'
|
16
|
+
s.required_ruby_version = '>= 1.8.7'
|
16
17
|
|
17
|
-
s.add_development_dependency('bundler')
|
18
|
-
s.add_development_dependency('rake')
|
19
|
-
s.add_development_dependency('rspec')
|
20
|
-
s.add_development_dependency('simplecov')
|
21
|
-
s.add_development_dependency('uuid')
|
18
|
+
s.add_development_dependency('bundler', '~> 1.6')
|
19
|
+
s.add_development_dependency('rake', '~> 10.1')
|
20
|
+
s.add_development_dependency('rspec', '~> 2.13')
|
21
|
+
s.add_development_dependency('simplecov', '~> 0.8')
|
22
22
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require './lib/attempt_this/binary_backoff_policy.rb'
|
2
|
+
require './lib/attempt_this/exception_type_filter.rb'
|
3
3
|
|
4
4
|
module AttemptThis
|
5
5
|
# Retry policy implementation.
|
@@ -29,29 +29,17 @@ module AttemptThis
|
|
29
29
|
return self unless block
|
30
30
|
return block.call unless AttemptThis.enabled?
|
31
31
|
|
32
|
-
|
33
|
-
first_time = true
|
32
|
+
apply_defaults
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@enumerator.rewind
|
40
|
-
@enumerator.with_index do |i|
|
41
|
-
@delay_policy.call unless i == 0
|
42
|
-
last_exception = nil
|
43
|
-
begin
|
44
|
-
return block.call
|
45
|
-
rescue Exception => ex
|
46
|
-
raise unless @exception_filter.include?(ex)
|
47
|
-
@reset_method.call
|
48
|
-
last_exception = ex
|
49
|
-
end
|
34
|
+
# Retriable attempts require special error handling
|
35
|
+
result = each_retriable_attempt do
|
36
|
+
return attempt_with_reset(&block)
|
50
37
|
end
|
51
38
|
|
52
|
-
|
53
|
-
|
54
|
-
|
39
|
+
# Final attempt
|
40
|
+
if (result != :empty)
|
41
|
+
@delay_policy.call unless result == :skipped
|
42
|
+
final_attempt(&block)
|
55
43
|
end
|
56
44
|
end
|
57
45
|
|
@@ -69,7 +57,7 @@ module AttemptThis
|
|
69
57
|
raise(ArgumentError, "Delay should be either an number or a range of numbers; got #{delay}!")
|
70
58
|
end
|
71
59
|
raise(ArgumentError, 'Delay policy has already been specified!') if @delay_policy
|
72
|
-
@delay_policy =
|
60
|
+
@delay_policy = lambda{Kernel.sleep(delay.first + rand(delay.count))}
|
73
61
|
|
74
62
|
attempt(block)
|
75
63
|
end
|
@@ -118,10 +106,52 @@ module AttemptThis
|
|
118
106
|
|
119
107
|
# Creates a scenario with the given id.
|
120
108
|
def scenario(id)
|
121
|
-
raise(ArgumentError, '
|
109
|
+
raise(ArgumentError, 'Nil id!') if id.nil?
|
122
110
|
raise(ArgumentError, "There is already a scenario with id #{id}") if @@scenarios.has_key?(id)
|
123
111
|
|
124
112
|
@@scenarios[id] = self
|
125
113
|
end
|
114
|
+
|
115
|
+
private
|
116
|
+
|
117
|
+
|
118
|
+
def final_attempt(&block)
|
119
|
+
attempt_with_reset(&block)
|
120
|
+
rescue Exception => ex
|
121
|
+
raise unless @default_method
|
122
|
+
raise unless @exception_filter.include?(ex)
|
123
|
+
@default_method.call
|
124
|
+
end
|
125
|
+
|
126
|
+
def apply_defaults
|
127
|
+
@delay_policy = lambda{} unless @delay_policy
|
128
|
+
@reset_method = lambda{} unless @reset_method
|
129
|
+
@exception_filter = ExceptionTypeFilter.new([StandardError]) unless @exception_filter
|
130
|
+
end
|
131
|
+
|
132
|
+
def each_retriable_attempt(&block)
|
133
|
+
result = :empty
|
134
|
+
@enumerator.each do
|
135
|
+
if (result == :empty)
|
136
|
+
result = :skipped
|
137
|
+
next
|
138
|
+
end
|
139
|
+
@delay_policy.call unless result == :skipped
|
140
|
+
result = :attempted
|
141
|
+
begin
|
142
|
+
block.call
|
143
|
+
rescue Exception => ex
|
144
|
+
raise unless @exception_filter.include?(ex)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
result
|
148
|
+
end
|
149
|
+
|
150
|
+
def attempt_with_reset(&block)
|
151
|
+
block.call
|
152
|
+
rescue Exception => ex
|
153
|
+
@reset_method.call
|
154
|
+
raise
|
155
|
+
end
|
126
156
|
end
|
127
157
|
end
|
data/spec/attempt_spec.rb
CHANGED
@@ -5,11 +5,11 @@ describe AttemptThis do
|
|
5
5
|
|
6
6
|
context 'attempt' do
|
7
7
|
it 'should reject nil enumerator' do
|
8
|
-
|
8
|
+
lambda{attempt(nil)}.should raise_error(ArgumentError)
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'should allow execution without a code block' do
|
12
|
-
|
12
|
+
lambda{attempt(3.times)}.should_not raise_error
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should execute code block' do
|
@@ -32,12 +32,12 @@ describe AttemptThis do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should re-throw the original exception' do
|
35
|
-
|
35
|
+
lambda{attempt(2.times){raise 'Test'}}.should raise_error('Test')
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should attempt 3 times' do
|
39
39
|
call_count = 0
|
40
|
-
|
40
|
+
lambda{attempt(3.times) { call_count += 1; raise 'Test'}}.should raise_error('Test')
|
41
41
|
call_count.should eql(3)
|
42
42
|
end
|
43
43
|
|
@@ -52,34 +52,34 @@ describe AttemptThis do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it 'should return block\'s value' do
|
55
|
-
expected =
|
55
|
+
expected = "some string"
|
56
56
|
attempt(3.times) { expected }.should eql(expected)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
context 'with_delay' do
|
61
61
|
it 'should reject nil delay' do
|
62
|
-
|
62
|
+
lambda{attempt(3.times).with_delay(nil)}.should raise_error(ArgumentError)
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'should reject negative delay' do
|
66
|
-
|
66
|
+
lambda{attempt(3.times).with_delay(-1)}.should raise_error(ArgumentError)
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should reject non-number delay' do
|
70
|
-
|
70
|
+
lambda{attempt(3.times).with_delay('foo')}.should raise_error(ArgumentError)
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should accept floating point delay' do
|
74
|
-
|
74
|
+
lambda{attempt(3.times).with_delay(1.5)}.should_not raise_error
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'should accept zero delay' do
|
78
|
-
|
78
|
+
lambda{attempt(3.times).with_delay(0)}.should_not raise_error
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'should accept calls without a code block' do
|
82
|
-
|
82
|
+
lambda{attempt(3.times).with_delay(3)}.should_not raise_error
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'should call the code block' do
|
@@ -97,111 +97,111 @@ describe AttemptThis do
|
|
97
97
|
|
98
98
|
it 'should sleep for given number of seconds between failed attempts' do
|
99
99
|
Kernel.should_receive(:sleep).with(5).exactly(2).times
|
100
|
-
|
100
|
+
lambda{attempt(3.times).with_delay(5) {raise 'Test'}}.should raise_error('Test')
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'should not fail on zero delay' do
|
104
|
-
|
104
|
+
lambda{attempt(3.times).with_delay(0) { raise 'Test' }}.should raise_error('Test')
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'should reject negative start' do
|
108
|
-
|
108
|
+
lambda{attempt(3.times).with_delay(-1..1)}.should raise_error(ArgumentError)
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'should reject negative end' do
|
112
|
-
|
112
|
+
lambda{attempt(3.times).with_delay(1..-1)}.should raise_error(ArgumentError)
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'should reject non-number range' do
|
116
|
-
|
116
|
+
lambda{attempt(3.times).with_delay('x'..'y')}.should raise_error(ArgumentError)
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'should accept floating point range' do
|
120
|
-
|
120
|
+
lambda{attempt(3.times).with_delay(1.5..3)}.should_not raise_error
|
121
121
|
end
|
122
122
|
|
123
123
|
it 'should reject inverse range' do
|
124
|
-
|
124
|
+
lambda{attempt(2.times).with_delay(3..1)}.should raise_error(ArgumentError)
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'should accept zero seconds interval' do
|
128
|
-
|
128
|
+
lambda{attempt(3.times).with_delay(0..0)}.should_not raise_error
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'should wait for specified number of seconds' do
|
132
132
|
Kernel.should_receive(:sleep).with(5).exactly(2).times
|
133
|
-
|
133
|
+
lambda{attempt(3.times).with_delay(5..5){raise 'Test'}}.should raise_error('Test')
|
134
134
|
end
|
135
135
|
|
136
136
|
it 'should reject multiple delay policies' do
|
137
|
-
|
137
|
+
lambda{attempt(3.times).with_delay(1).with_delay(1)}.should raise_error(ArgumentError)
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
141
|
context 'with_reset' do
|
142
142
|
it 'should reject nil reset proc' do
|
143
|
-
|
143
|
+
lambda{attempt(3.times).with_reset(nil)}.should raise_error(ArgumentError)
|
144
144
|
end
|
145
145
|
|
146
146
|
it 'should accept calls without a code block' do
|
147
|
-
|
147
|
+
lambda{attempt(3.times).with_reset(lambda{})}.should_not raise_error
|
148
148
|
end
|
149
149
|
|
150
150
|
it 'should call the code block' do
|
151
151
|
was_called = false
|
152
|
-
attempt(1.times).with_reset(
|
152
|
+
attempt(1.times).with_reset(lambda{}) { was_called = true }
|
153
153
|
|
154
154
|
was_called.should be_true
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'should reject multiple reset procs' do
|
158
|
-
|
158
|
+
lambda{attempt(3.times).with_reset(lambda{}).with_reset(lambda{})}.should raise_error(ArgumentError)
|
159
159
|
end
|
160
160
|
|
161
161
|
it 'should not be called on successful calls' do
|
162
162
|
was_called = false
|
163
163
|
|
164
|
-
attempt(1.times).with_reset(
|
164
|
+
attempt(1.times).with_reset(lambda{ was_called = true }) {}
|
165
165
|
was_called.should be_false
|
166
166
|
end
|
167
167
|
|
168
168
|
it 'should be called on each failure' do
|
169
169
|
reset_count = 0
|
170
170
|
|
171
|
-
|
171
|
+
lambda{attempt(3.times).with_reset(lambda{ reset_count += 1 }) { raise 'Test' }}.should raise_error('Test')
|
172
172
|
reset_count.should eql(3)
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
176
|
context 'and_default_to' do
|
177
177
|
it 'should reject nil default method' do
|
178
|
-
|
178
|
+
lambda{attempt(3.times).and_default_to(nil)}.should raise_error(ArgumentError)
|
179
179
|
end
|
180
180
|
|
181
181
|
it 'should reject duplicate default methods' do
|
182
|
-
|
182
|
+
lambda{attempt(3.times).and_default_to(lambda{}).and_default_to(lambda{})}.should raise_error(ArgumentError)
|
183
183
|
end
|
184
184
|
|
185
185
|
it 'should allow calls without a code block' do
|
186
|
-
|
186
|
+
lambda{attempt(3.times).and_default_to(lambda{})}.should_not raise_error
|
187
187
|
end
|
188
188
|
|
189
189
|
it 'should call the code block' do
|
190
190
|
was_called = false
|
191
|
-
attempt(3.times).and_default_to(
|
191
|
+
attempt(3.times).and_default_to(lambda{}){ was_called = true }
|
192
192
|
|
193
193
|
was_called.should be_true
|
194
194
|
end
|
195
195
|
|
196
196
|
it 'should not be called on success' do
|
197
197
|
was_called = false
|
198
|
-
attempt(3.times).and_default_to(
|
198
|
+
attempt(3.times).and_default_to(lambda{ was_called = true }) {}
|
199
199
|
was_called.should be_false
|
200
200
|
end
|
201
201
|
|
202
202
|
it 'should be called once on the failure' do
|
203
203
|
call_count = 0
|
204
|
-
attempt(3.times).and_default_to(
|
204
|
+
attempt(3.times).and_default_to(lambda{ call_count += 1 }){ raise 'Test'}
|
205
205
|
|
206
206
|
call_count.should eql(1)
|
207
207
|
end
|
@@ -210,34 +210,34 @@ describe AttemptThis do
|
|
210
210
|
call_count = 0
|
211
211
|
was_called = false
|
212
212
|
|
213
|
-
attempt(3.times).and_default_to(
|
213
|
+
attempt(3.times).and_default_to(lambda{ was_called = true }) { call_count += 1; raise 'Test' if call_count < 2 }
|
214
214
|
was_called.should be_false
|
215
215
|
end
|
216
216
|
end
|
217
217
|
|
218
218
|
context 'with_binary_backoff' do
|
219
219
|
it 'should reject nil initial delay' do
|
220
|
-
|
220
|
+
lambda{attempt(3.times).with_binary_backoff(nil)}.should raise_error(ArgumentError)
|
221
221
|
end
|
222
222
|
|
223
223
|
it 'should reject non-integer initial delay' do
|
224
|
-
|
224
|
+
lambda{attempt(3.times).with_binary_backoff('foo')}.should raise_error(ArgumentError)
|
225
225
|
end
|
226
226
|
|
227
227
|
it 'should reject zero initial delay' do
|
228
|
-
|
228
|
+
lambda{attempt(3.times).with_binary_backoff(0)}.should raise_error(ArgumentError)
|
229
229
|
end
|
230
230
|
|
231
231
|
it 'should reject negative initial delay' do
|
232
|
-
|
232
|
+
lambda{attempt(3.times).with_binary_backoff(-1)}.should raise_error(ArgumentError)
|
233
233
|
end
|
234
234
|
|
235
235
|
it 'should reject multiple policies' do
|
236
|
-
|
236
|
+
lambda{attempt(3.times).with_binary_backoff(1).with_binary_backoff(2)}.should raise_error(ArgumentError)
|
237
237
|
end
|
238
238
|
|
239
239
|
it 'should accept calls without a code block' do
|
240
|
-
|
240
|
+
lambda{attempt(3.times).with_binary_backoff(1)}.should_not raise_error
|
241
241
|
end
|
242
242
|
|
243
243
|
it 'should call the code block' do
|
@@ -252,21 +252,21 @@ describe AttemptThis do
|
|
252
252
|
Kernel.should_receive(:sleep).ordered.with(2)
|
253
253
|
Kernel.should_receive(:sleep).ordered.with(4)
|
254
254
|
|
255
|
-
attempt(4.times).with_binary_backoff(1).and_default_to(
|
255
|
+
attempt(4.times).with_binary_backoff(1).and_default_to(lambda{}) { raise 'Test' }
|
256
256
|
end
|
257
257
|
end
|
258
258
|
|
259
259
|
context 'with_filter' do
|
260
260
|
it 'should reject empty exceptions list' do
|
261
|
-
|
261
|
+
lambda{attempt.with_filter}.should raise_error(ArgumentError)
|
262
262
|
end
|
263
263
|
|
264
264
|
it 'should reject non-exceptions' do
|
265
|
-
|
265
|
+
lambda{attempt.with_filter(1)}.should raise_error(ArgumentError)
|
266
266
|
end
|
267
267
|
|
268
268
|
it 'should accept calls without a block' do
|
269
|
-
|
269
|
+
lambda{attempt(2.times).with_filter(Exception)}.should_not raise_error
|
270
270
|
end
|
271
271
|
|
272
272
|
it 'should call code within the block' do
|
@@ -277,19 +277,19 @@ describe AttemptThis do
|
|
277
277
|
|
278
278
|
it 'should ignore other exceptions' do
|
279
279
|
count = 0
|
280
|
-
|
280
|
+
lambda{attempt(3.times).with_filter(StandardError){ count += 1; raise(Exception, 'Test')}}.should raise_error(Exception)
|
281
281
|
count.should eql(1)
|
282
282
|
end
|
283
283
|
|
284
284
|
it 'should not ignore specified exceptions' do
|
285
285
|
count = 0
|
286
|
-
|
286
|
+
lambda{attempt(3.times).with_filter(RuntimeError){ count += 1; raise 'Test'}}.should raise_error(RuntimeError)
|
287
287
|
count.should eql(3)
|
288
288
|
end
|
289
289
|
|
290
290
|
it 'should not ignore derived exceptions' do
|
291
291
|
count = 0
|
292
|
-
|
292
|
+
lambda{attempt(3.times).with_filter(Exception){ count += 1; raise(StandardError, 'Test')}}.should raise_error(StandardError)
|
293
293
|
count.should eql(3)
|
294
294
|
end
|
295
295
|
end
|
data/spec/scenarios_spec.rb
CHANGED
@@ -9,24 +9,20 @@ describe AttemptThis do
|
|
9
9
|
|
10
10
|
context 'validation' do
|
11
11
|
it 'should reject nil scenario id' do
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should reject empty scenario id' do
|
16
|
-
->{AttemptThis.attempt(3.times).scenario('')}.should raise_error(ArgumentError)
|
12
|
+
lambda{AttemptThis.attempt(3.times).scenario(nil)}.should raise_error(ArgumentError)
|
17
13
|
end
|
18
14
|
|
19
15
|
it 'should accept string ids' do
|
20
|
-
|
16
|
+
lambda{AttemptThis.attempt(3.times).scenario('uploads')}.should_not raise_error
|
21
17
|
end
|
22
18
|
|
23
19
|
it 'should accept symbol ids' do
|
24
|
-
|
20
|
+
lambda{AttemptThis.attempt(3.times).scenario(:uploads)}.should_not raise_error
|
25
21
|
end
|
26
22
|
|
27
23
|
it 'should reject duplicate names' do
|
28
24
|
AttemptThis.attempt(3.times).scenario(:uploads)
|
29
|
-
|
25
|
+
lambda{AttemptThis.attempt(3.times).scenario(:uploads)}.should raise_error(ArgumentError)
|
30
26
|
end
|
31
27
|
end
|
32
28
|
|
@@ -35,16 +31,16 @@ describe AttemptThis do
|
|
35
31
|
AttemptThis.attempt(3.times).scenario(:test)
|
36
32
|
count = 0
|
37
33
|
|
38
|
-
|
34
|
+
lambda{attempt(:test) { count += 1; raise 'Test' }}.should raise_error('Test')
|
39
35
|
count.should eql(3)
|
40
36
|
end
|
41
37
|
|
42
38
|
it 'should reuse scenario' do
|
43
39
|
AttemptThis.attempt(3.times).scenario(:test)
|
44
|
-
|
40
|
+
lambda{attempt(:test) { raise 'Test'}}.should raise_error('Test')
|
45
41
|
|
46
42
|
count = 0
|
47
|
-
|
43
|
+
lambda{attempt(:test) {count += 1; raise 'Test'}}.should raise_error('Test')
|
48
44
|
count.should eql(3)
|
49
45
|
end
|
50
46
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,85 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attempt_this
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aliaksei Baturytski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '10.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '10.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.13'
|
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: '
|
54
|
+
version: '2.13'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '0.8'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: uuid
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
68
|
+
version: '0.8'
|
83
69
|
description: |
|
84
70
|
Retry policy mix-in with configurable number of attempts, delays, exception filters, and fall back strategies.
|
85
71
|
|
@@ -89,7 +75,8 @@ executables: []
|
|
89
75
|
extensions: []
|
90
76
|
extra_rdoc_files: []
|
91
77
|
files:
|
92
|
-
- .gitignore
|
78
|
+
- ".gitignore"
|
79
|
+
- ".travis.yml"
|
93
80
|
- Gemfile
|
94
81
|
- Gemfile.lock
|
95
82
|
- README.md
|
@@ -113,17 +100,17 @@ require_paths:
|
|
113
100
|
- lib
|
114
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
102
|
requirements:
|
116
|
-
- -
|
103
|
+
- - ">="
|
117
104
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
105
|
+
version: 1.8.7
|
119
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
107
|
requirements:
|
121
|
-
- -
|
108
|
+
- - ">="
|
122
109
|
- !ruby/object:Gem::Version
|
123
110
|
version: '0'
|
124
111
|
requirements: []
|
125
112
|
rubyforge_project:
|
126
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.2.2
|
127
114
|
signing_key:
|
128
115
|
specification_version: 4
|
129
116
|
summary: Retry policy mix-in
|