sidekiq-promise 0.1.0 → 0.1.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65cb4f994852f81d01a64430041c30bc5b801a61
|
4
|
+
data.tar.gz: d9946fa79e57b00e79147dedb917a4f132e09e06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95cd8e902837931b931134b0f1ee81e206ec9f79899902b4a4db3263c18979b0d9df079c2431e1d3d2921d30ae977dd7d8fa613fa0e8bed0a0c2c95b12525f29
|
7
|
+
data.tar.gz: c7907bfa3d88b5a8f53aac87841f69bdc624a843b86f79616227040cb9aeed3273669b19d0c8cbe52decf0f9ec78f5bb448596bd028bf82007a8b9dc8ed2a81d
|
@@ -4,13 +4,20 @@ module Sidekiq
|
|
4
4
|
|
5
5
|
def call worker, job, queue
|
6
6
|
job_dequeued job
|
7
|
-
yield
|
7
|
+
result = yield
|
8
|
+
result.raise if thenable? result
|
8
9
|
job_completed job
|
9
10
|
rescue Exception => e
|
10
11
|
job_errored job, e
|
11
12
|
raise e
|
12
13
|
end
|
13
14
|
|
15
|
+
private
|
16
|
+
|
17
|
+
def thenable? obj
|
18
|
+
obj.respond_to?(:then) && obj.respond_to?(:fail)
|
19
|
+
end
|
20
|
+
|
14
21
|
end
|
15
22
|
end
|
16
23
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Promising to fail job as promise' do
|
4
|
+
before(:all) { start_worker }
|
5
|
+
after(:all) { kill_worker }
|
6
|
+
before { clear_jobs }
|
7
|
+
after { clear_jobs }
|
8
|
+
|
9
|
+
let(:promise) { PromisingToFailWorker.as_promise }
|
10
|
+
subject { promise }
|
11
|
+
|
12
|
+
its(:final) { should_not be_resolved }
|
13
|
+
its(:final) { should be_rejected }
|
14
|
+
|
15
|
+
describe '#then' do
|
16
|
+
it 'does not yield' do
|
17
|
+
expect { |b| promise.final.then(&b) }.not_to yield_control
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#fail' do
|
22
|
+
it 'yields' do
|
23
|
+
expect { |b| promise.final.fail(&b) }.to yield_control
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-promise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Harton
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- spec/acceptance/crashing_job_spec.rb
|
176
176
|
- spec/acceptance/failing_job_spec.rb
|
177
177
|
- spec/acceptance/promising_job_spec.rb
|
178
|
+
- spec/acceptance/promising_to_fail_worker_spec.rb
|
178
179
|
- spec/lib/sidekiq/promise/client_middleware_spec.rb
|
179
180
|
- spec/lib/sidekiq/promise/middleware_spec.rb
|
180
181
|
- spec/lib/sidekiq/promise/server_middleware_spec.rb
|
@@ -185,6 +186,7 @@ files:
|
|
185
186
|
- spec/support/mock_client_pool.rb
|
186
187
|
- spec/support/sidekiq_helpers.rb
|
187
188
|
- spec/workers/crashy_worker.rb
|
189
|
+
- spec/workers/promising_to_fail_worker.rb
|
188
190
|
- spec/workers/promising_worker.rb
|
189
191
|
- spec/workers/raisey_worker.rb
|
190
192
|
- spec/workers/sleepy_worker.rb
|
@@ -217,6 +219,7 @@ test_files:
|
|
217
219
|
- spec/acceptance/crashing_job_spec.rb
|
218
220
|
- spec/acceptance/failing_job_spec.rb
|
219
221
|
- spec/acceptance/promising_job_spec.rb
|
222
|
+
- spec/acceptance/promising_to_fail_worker_spec.rb
|
220
223
|
- spec/lib/sidekiq/promise/client_middleware_spec.rb
|
221
224
|
- spec/lib/sidekiq/promise/middleware_spec.rb
|
222
225
|
- spec/lib/sidekiq/promise/server_middleware_spec.rb
|
@@ -227,6 +230,7 @@ test_files:
|
|
227
230
|
- spec/support/mock_client_pool.rb
|
228
231
|
- spec/support/sidekiq_helpers.rb
|
229
232
|
- spec/workers/crashy_worker.rb
|
233
|
+
- spec/workers/promising_to_fail_worker.rb
|
230
234
|
- spec/workers/promising_worker.rb
|
231
235
|
- spec/workers/raisey_worker.rb
|
232
236
|
- spec/workers/sleepy_worker.rb
|