aboutsummaryrefslogtreecommitdiffstats
path: root/spec/services
diff options
context:
space:
mode:
authorRobert2017-07-27 07:43:17 +0200
committerRobert2017-07-27 12:30:58 +0200
commit3bd8ff47f8c5e0477372cae9ddb6c4f5915c5ca3 (patch)
tree13ff9a15d7da9abf6f4dddc574232fb9ccd6893d /spec/services
parent96a6ae08191b465a91b285cf157223c0a898ed5d (diff)
downloadchouette-core-3bd8ff47f8c5e0477372cae9ddb6c4f5915c5ca3.tar.bz2
Fixes: #3507@1.5h Retries & Error Handling in WorkbenchImportWorker
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/retry_service_spec.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/spec/services/retry_service_spec.rb b/spec/services/retry_service_spec.rb
index 0ab9ddef9..22957b565 100644
--- a/spec/services/retry_service_spec.rb
+++ b/spec/services/retry_service_spec.rb
@@ -96,19 +96,24 @@ RSpec.describe RetryService do
context 'failure callback in constructor' do
subject do
- described_class.new(delays: [1]){ @failures += 1}
+ described_class.new(delays: [1, 2], &method(:add2failures))
end
before do
- @failures = 0
+ @failures = []
@count = 0
expect( subject ).to receive(:sleep).with(1)
+ expect( subject ).to receive(:sleep).with(2)
end
it 'succeeds the second time and calls the failure_callback once' do
- subject.execute{ succeed_later(RetryService::Retry){ 42 } }
- expect( @failures ).to eq(1)
+ subject.execute{ succeed_later(RetryService::Retry, count: 2){ 42 } }
+ expect( @failures ).to eq([1,2])
end
end
+ def add2failures( e, c)
+ @failures << c
+ end
+
def succeed_later error, count: 1, &blk
return blk.() unless @count < count
@count += 1