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: 42bd79021c80180e745f9955f20d79676cec7a0a
4
- data.tar.gz: c83c3a33895da56df06b0d7e59bec12a60dd431d
3
+ metadata.gz: 65cb4f994852f81d01a64430041c30bc5b801a61
4
+ data.tar.gz: d9946fa79e57b00e79147dedb917a4f132e09e06
5
5
  SHA512:
6
- metadata.gz: 5fae2380872872ed025174c8283d4673dee9454a67a60e7d6716e760cf1344b3e6f5df0d2e62bf64d17975a7e5a6b16c81a0b855d7bd2e534a80616a2b2ad1b5
7
- data.tar.gz: 110ae879d59744fd1a21ffbf1dbdf034d243901348ab9877b21a4358c759bc2ab3b816e18438d16f290a79f9a802910d6b84ea54736b33ba0cc5ab94d5ba4e57
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
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Promise
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  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
@@ -0,0 +1,10 @@
1
+ class PromisingToFailWorker
2
+ include Sidekiq::Promise
3
+
4
+ def perform
5
+ MrDarcy.promise do
6
+ sleep 0.5
7
+ reject "for the LOLs"
8
+ end
9
+ end
10
+ end
@@ -6,6 +6,6 @@ class PromisingWorker
6
6
  10.times.map do
7
7
  SleepyWorker.as_promise 1
8
8
  end
9
- end.final
9
+ end
10
10
  end
11
11
  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.0
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