rspec-sidekiq 1.0.0 → 1.1.0
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 +8 -8
- data/.gitignore +1 -1
- data/.rspec +2 -1
- data/.simplecov +4 -3
- data/CHANGES.md +10 -0
- data/README.md +3 -6
- data/lib/rspec-sidekiq.rb +2 -1
- data/lib/rspec/sidekiq/batch.rb +19 -6
- data/lib/rspec/sidekiq/helpers/within_sidekiq_retries_exhausted_block.rb +10 -2
- data/lib/rspec/sidekiq/matchers/be_delayed.rb +2 -1
- data/lib/rspec/sidekiq/matchers/be_processed_in.rb +2 -1
- data/lib/rspec/sidekiq/matchers/be_retryable.rb +2 -1
- data/lib/rspec/sidekiq/matchers/be_unique.rb +3 -2
- data/lib/rspec/sidekiq/matchers/have_enqueued_job.rb +2 -1
- data/lib/rspec/sidekiq/version.rb +2 -2
- data/rspec-sidekiq.gemspec +1 -3
- data/spec/rspec/sidekiq/batch_spec.rb +17 -4
- data/spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb +11 -0
- data/spec/rspec/sidekiq/matchers/be_unique_spec.rb +44 -32
- data/spec/rspec/sidekiq/version_spec.rb +2 -2
- metadata +11 -39
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTM0OGMwZTYyZGY4NTFkOTU0MjlhNGMxZDUzYTJmMzI5N2MwNTE1Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yzc5YWUwMWYwN2VlNzc4ZDlmNDI2OWQyOWNlMjJhOWRjYWI4Y2Q4Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTZkOWEyNzk2MTNhMzA4MzE5ZmE0MmE2MWU2NTQ5ZDJmMzcwYzZkOTViY2U3
|
10
|
+
MTFkMDEwMWIzYjE3NTRkZTA4MzU2Mjc0ZDAxZGY2Y2ZlNjQ2NGQ4YjI0NGQ2
|
11
|
+
M2FhYTg0MTg5YmU2YjQwYjQyMDI2M2NhZWUzZTM3ZmZiODY3Yzk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmZiOTNjOGYxMGFhOTdhZDlmNDZiMjI5NDVkOWQ0ZjMyNGViZDJmNzI5ZGI3
|
14
|
+
ZmM1YmYxYjEwODRlYzIxZjk3MmE2OTkzNDc1ZWJjMGJhYjI4MmMwMDBlNGY3
|
15
|
+
NzA5ODgzY2Y3ZTNhNTM0YmFkMWVjMWQ5ZGMyZDMxMmJlMDhkZDM=
|
data/.gitignore
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
Gemfile.lock
|
2
|
-
|
2
|
+
spec/result
|
data/.rspec
CHANGED
data/.simplecov
CHANGED
data/CHANGES.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
1.1.0
|
2
|
+
---
|
3
|
+
* Added Support for RSpec 3 [TBAA#44]
|
4
|
+
* Fix gem build error ERROR: (Gem::InvalidSpecificationException) [mourad-ifeelgoods#42]
|
5
|
+
* Make sure sidekiq is required [mourad-ifeelgoods#43]
|
6
|
+
* attempt at fixing 'undefined method `configure' for RSpec:Module' [homanchou#51]
|
7
|
+
* Supports accessing the batch id [fabiokr#54]
|
8
|
+
* Pass message hash to retries_exhausted block [layervault#52]
|
9
|
+
* added support for unique scheduled worker matching [jkogara#55]
|
10
|
+
|
1
11
|
1.0.0
|
2
12
|
---
|
3
13
|
* Improve coverage and readability of README [philostler#26]
|
data/README.md
CHANGED
@@ -5,9 +5,8 @@
|
|
5
5
|
[![Travis CI][travis_ci_badge]][travis_ci]
|
6
6
|
[![Coveralls][coveralls_badge]][coveralls]
|
7
7
|
[![Gemnasium][gemnasium_badge]][gemnasium]
|
8
|
-
[![coderwall][coderwall_badge]][coderwall]
|
9
8
|
|
10
|
-
|
9
|
+
***Simple testing of Sidekiq jobs via a collection of matchers and helpers***
|
11
10
|
|
12
11
|
[RubyGems][ruby_gems] |
|
13
12
|
[Code Climate][code_climate] |
|
@@ -162,19 +161,17 @@ Issues/Pull Requests/Comments all welcome...
|
|
162
161
|
|
163
162
|
[code_climate]: https://codeclimate.com/github/philostler/rspec-sidekiq
|
164
163
|
[code_climate_badge]: https://codeclimate.com/github/philostler/rspec-sidekiq.png
|
165
|
-
[coderwall]: https://coderwall.com/philostler
|
166
|
-
[coderwall_badge]: https://api.coderwall.com/philostler/endorsecount.png
|
167
164
|
[coveralls]: https://coveralls.io/r/philostler/rspec-sidekiq
|
168
165
|
[coveralls_badge]: https://coveralls.io/repos/philostler/rspec-sidekiq/badge.png?branch=master
|
169
166
|
[gem_version_badge]: https://badge.fury.io/rb/rspec-sidekiq.png
|
170
167
|
[gemnasium]: https://gemnasium.com/philostler/rspec-sidekiq
|
171
168
|
[gemnasium_badge]: https://gemnasium.com/philostler/rspec-sidekiq.png
|
172
169
|
[github]: http://github.com/philostler/rspec-sidekiq
|
173
|
-
[ruby_doc]: http://rubydoc.info/
|
170
|
+
[ruby_doc]: http://rubydoc.info/gems/rspec-sidekiq/frames
|
174
171
|
[ruby_gems]: http://rubygems.org/gems/rspec-sidekiq
|
175
172
|
[ruby_toolbox]: http://www.ruby-toolbox.com/projects/rspec-sidekiq
|
176
173
|
[travis_ci]: http://travis-ci.org/philostler/rspec-sidekiq
|
177
|
-
[travis_ci_badge]: https://
|
174
|
+
[travis_ci_badge]: https://travis-ci.org/philostler/rspec-sidekiq.svg?branch=master
|
178
175
|
|
179
176
|
[rspec_sidekiq_wiki_faq_&_troubleshooting]: https://github.com/philostler/rspec-sidekiq/wiki/FAQ-&-Troubleshooting
|
180
177
|
[sidekiq_wiki_batches]: https://github.com/mperham/sidekiq/wiki/Batches
|
data/lib/rspec-sidekiq.rb
CHANGED
data/lib/rspec/sidekiq/batch.rb
CHANGED
@@ -1,22 +1,37 @@
|
|
1
|
+
require "rspec/core"
|
2
|
+
|
1
3
|
if defined? Sidekiq::Batch
|
2
4
|
module RSpec
|
3
5
|
module Sidekiq
|
4
6
|
class NullObject
|
5
|
-
def initialize(*)
|
6
|
-
end
|
7
|
-
|
8
7
|
def method_missing(*args, &block)
|
9
8
|
self
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
13
12
|
class NullBatch < NullObject
|
13
|
+
attr_reader :bid
|
14
|
+
|
15
|
+
def initialize(bid = nil)
|
16
|
+
@bid = bid || SecureRandom.hex(8)
|
17
|
+
end
|
18
|
+
|
19
|
+
def status
|
20
|
+
NullStatus.new(@bid)
|
21
|
+
end
|
22
|
+
|
14
23
|
def jobs(*)
|
15
24
|
yield
|
16
25
|
end
|
17
26
|
end
|
18
27
|
|
19
28
|
class NullStatus < NullObject
|
29
|
+
attr_reader :bid
|
30
|
+
|
31
|
+
def initialize(bid)
|
32
|
+
@bid = bid
|
33
|
+
end
|
34
|
+
|
20
35
|
def join
|
21
36
|
::Sidekiq::Worker.drain_all
|
22
37
|
end
|
@@ -32,10 +47,8 @@ if defined? Sidekiq::Batch
|
|
32
47
|
config.before(:each) do
|
33
48
|
if mocked_with_mocha?
|
34
49
|
Sidekiq::Batch.stubs(:new) { RSpec::Sidekiq::NullBatch.new }
|
35
|
-
Sidekiq::Batch::Status.stubs(:new) { RSpec::Sidekiq::NullStatus.new }
|
36
50
|
else
|
37
51
|
Sidekiq::Batch.stub(:new) { RSpec::Sidekiq::NullBatch.new }
|
38
|
-
Sidekiq::Batch::Status.stub(:new) { RSpec::Sidekiq::NullStatus.new }
|
39
52
|
end
|
40
53
|
end
|
41
54
|
end
|
@@ -44,4 +57,4 @@ if defined? Sidekiq::Batch
|
|
44
57
|
def mocked_with_mocha?
|
45
58
|
Sidekiq::Batch.respond_to? :stubs
|
46
59
|
end
|
47
|
-
end
|
60
|
+
end
|
@@ -1,10 +1,18 @@
|
|
1
1
|
module Sidekiq
|
2
2
|
module Worker
|
3
3
|
module ClassMethods
|
4
|
-
def within_sidekiq_retries_exhausted_block &block
|
4
|
+
def within_sidekiq_retries_exhausted_block user_msg = {}, &block
|
5
5
|
block.call
|
6
|
+
self.sidekiq_retries_exhausted_block.call default_retries_exhausted_args.merge(user_msg)
|
7
|
+
end
|
6
8
|
|
7
|
-
|
9
|
+
def default_retries_exhausted_args
|
10
|
+
{
|
11
|
+
'queue' => get_sidekiq_options[:worker],
|
12
|
+
'class' => self.name,
|
13
|
+
'args' => [],
|
14
|
+
'error_message' => 'An error occured'
|
15
|
+
}
|
8
16
|
end
|
9
17
|
end
|
10
18
|
end
|
@@ -46,6 +46,7 @@ module RSpec
|
|
46
46
|
def negative_failure_message
|
47
47
|
"expected #{@expected_method.receiver}.#{@expected_method.name} to not " + description
|
48
48
|
end
|
49
|
+
alias_method :failure_message_when_negated, :negative_failure_message
|
49
50
|
|
50
51
|
def until time
|
51
52
|
@expected_time = time
|
@@ -64,4 +65,4 @@ module RSpec
|
|
64
65
|
end
|
65
66
|
end
|
66
67
|
end
|
67
|
-
end
|
68
|
+
end
|
@@ -17,13 +17,14 @@ module RSpec
|
|
17
17
|
def matches? job
|
18
18
|
@klass = job.kind_of?(Class) ? job : job.class
|
19
19
|
@actual = @klass.get_sidekiq_options["unique"]
|
20
|
-
@actual
|
20
|
+
[true, :all].include?(@actual)
|
21
21
|
end
|
22
22
|
|
23
23
|
def negative_failure_message
|
24
24
|
"expected #{@klass} to not be unique in the queue"
|
25
25
|
end
|
26
|
+
alias_method :failure_message_when_negated, :negative_failure_message
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
29
|
-
end
|
30
|
+
end
|
data/rspec-sidekiq.gemspec
CHANGED
@@ -12,13 +12,11 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.description = "Simple testing of Sidekiq jobs via a collection of matchers and helpers"
|
13
13
|
s.license = "MIT"
|
14
14
|
|
15
|
-
s.add_dependency "rspec", "
|
15
|
+
s.add_dependency "rspec", "~> 2.0"
|
16
16
|
s.add_dependency "sidekiq", ">= 2.4.0"
|
17
17
|
|
18
18
|
s.add_development_dependency "coveralls", "~> 0.7.0"
|
19
19
|
s.add_development_dependency "fuubar", ">= 1.1.0"
|
20
|
-
s.add_development_dependency "rspec", ">= 2.0.0"
|
21
|
-
s.add_development_dependency "sidekiq", ">= 2.4.0"
|
22
20
|
|
23
21
|
s.files = Dir[".gitattributes"] +
|
24
22
|
Dir[".gitignore"] +
|
@@ -13,15 +13,28 @@ describe "Batch" do
|
|
13
13
|
describe "NullStatus" do
|
14
14
|
describe "#total" do
|
15
15
|
it "returns 0 when no jobs" do
|
16
|
-
null_status =
|
16
|
+
null_status = Sidekiq::Batch.new.status
|
17
17
|
expect(null_status.total).to eq(0)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "returns 1 when 1 job" do
|
21
|
-
|
22
|
-
|
21
|
+
batch = Sidekiq::Batch.new
|
22
|
+
|
23
|
+
batch.jobs do
|
24
|
+
TestWorker.perform_async('5')
|
25
|
+
end
|
26
|
+
|
27
|
+
null_status = batch.status
|
28
|
+
|
23
29
|
expect(null_status.total).to eq(1)
|
24
30
|
end
|
25
31
|
end
|
32
|
+
|
33
|
+
describe "#bid" do
|
34
|
+
it "returns a bid" do
|
35
|
+
null_status = Sidekiq::Batch.new
|
36
|
+
expect(null_status.bid).to_not be_nil
|
37
|
+
end
|
38
|
+
end
|
26
39
|
end
|
27
|
-
end
|
40
|
+
end
|
@@ -5,14 +5,25 @@ describe 'Retries Exhausted block' do
|
|
5
5
|
class FooClass < TestWorkerAlternative
|
6
6
|
sidekiq_retries_exhausted do |msg|
|
7
7
|
bar('hello')
|
8
|
+
foo(msg)
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.bar(input)
|
11
12
|
end
|
13
|
+
|
14
|
+
def self.foo(msg)
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
it 'executes whatever is within the block' do
|
15
19
|
FooClass.within_sidekiq_retries_exhausted_block { expect(FooClass).to receive(:bar).with('hello') }
|
16
20
|
end
|
17
21
|
|
22
|
+
it 'passes arguments to the block' do
|
23
|
+
args = {'args' => ['a', 'b']}
|
24
|
+
FooClass.within_sidekiq_retries_exhausted_block(args) do
|
25
|
+
expect(FooClass).to receive(:foo).with(FooClass.default_retries_exhausted_args.merge(args))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
18
29
|
end
|
@@ -1,50 +1,62 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe RSpec::Sidekiq::Matchers::BeUnique do
|
4
|
-
|
5
|
-
|
4
|
+
shared_context "a unique worker" do
|
5
|
+
before(:each) { subject.matches? @worker }
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
describe "expected usage" do
|
8
|
+
it "matches" do
|
9
|
+
expect(@worker).to be_unique
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#failure_message" do
|
13
|
+
it "returns message" do
|
14
|
+
expect(subject.failure_message).to eq "expected #{@worker} to be unique in the queue"
|
15
|
+
end
|
16
|
+
end
|
12
17
|
|
13
|
-
describe "#be_unique" do
|
14
|
-
it "returns instance" do
|
15
|
-
expect(be_unique).to be_a RSpec::Sidekiq::Matchers::BeUnique
|
16
18
|
end
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
describe "#matches?" do
|
21
|
+
context "when condition matches" do
|
22
|
+
it "returns true" do
|
23
|
+
expect(subject.matches? @worker).to be true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when condition does not match" do
|
28
|
+
it "returns false" do
|
29
|
+
expect(subject.matches? create_worker unique: false).to be false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#negative_failure_message" do
|
34
|
+
it "returns message" do
|
35
|
+
expect(subject.negative_failure_message).to eq "expected #{@worker} to not be unique in the queue"
|
36
|
+
end
|
37
|
+
end
|
22
38
|
end
|
23
39
|
end
|
24
40
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
41
|
+
context "a scheduled worker" do
|
42
|
+
before { @worker = create_worker unique: :all }
|
43
|
+
include_context "a unique worker"
|
29
44
|
end
|
30
45
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
46
|
+
context "a regular worker" do
|
47
|
+
before { @worker = create_worker unique: true}
|
48
|
+
include_context "a unique worker"
|
49
|
+
end
|
37
50
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
51
|
+
describe "#be_unique" do
|
52
|
+
it "returns instance" do
|
53
|
+
expect(be_unique).to be_a RSpec::Sidekiq::Matchers::BeUnique
|
42
54
|
end
|
43
55
|
end
|
44
56
|
|
45
|
-
describe "#
|
46
|
-
it "returns
|
47
|
-
expect(subject.
|
57
|
+
describe "#description" do
|
58
|
+
it "returns description" do
|
59
|
+
expect(subject.description).to eq "be unique in the queue"
|
48
60
|
end
|
49
61
|
end
|
50
|
-
end
|
62
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Ostler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
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: 2.0
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sidekiq
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,34 +66,6 @@ dependencies:
|
|
66
66
|
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.1.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ! '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 2.0.0
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ! '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 2.0.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: sidekiq
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ! '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 2.4.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ! '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 2.4.0
|
97
69
|
description: Simple testing of Sidekiq jobs via a collection of matchers and helpers
|
98
70
|
email: github@philostler.com
|
99
71
|
executables: []
|
@@ -108,21 +80,21 @@ files:
|
|
108
80
|
- Gemfile
|
109
81
|
- LICENSE
|
110
82
|
- README.md
|
111
|
-
- rspec-sidekiq.
|
83
|
+
- lib/rspec-sidekiq.rb
|
112
84
|
- lib/rspec/sidekiq/batch.rb
|
113
85
|
- lib/rspec/sidekiq/configuration.rb
|
114
|
-
- lib/rspec/sidekiq/helpers/within_sidekiq_retries_exhausted_block.rb
|
115
86
|
- lib/rspec/sidekiq/helpers.rb
|
87
|
+
- lib/rspec/sidekiq/helpers/within_sidekiq_retries_exhausted_block.rb
|
88
|
+
- lib/rspec/sidekiq/matchers.rb
|
116
89
|
- lib/rspec/sidekiq/matchers/be_delayed.rb
|
117
90
|
- lib/rspec/sidekiq/matchers/be_processed_in.rb
|
118
91
|
- lib/rspec/sidekiq/matchers/be_retryable.rb
|
119
92
|
- lib/rspec/sidekiq/matchers/be_unique.rb
|
120
93
|
- lib/rspec/sidekiq/matchers/have_enqueued_job.rb
|
121
94
|
- lib/rspec/sidekiq/matchers/have_enqueued_jobs.rb
|
122
|
-
- lib/rspec/sidekiq/matchers.rb
|
123
95
|
- lib/rspec/sidekiq/sidekiq.rb
|
124
96
|
- lib/rspec/sidekiq/version.rb
|
125
|
-
-
|
97
|
+
- rspec-sidekiq.gemspec
|
126
98
|
- spec/rspec/sidekiq/batch_spec.rb
|
127
99
|
- spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb
|
128
100
|
- spec/rspec/sidekiq/matchers/be_delayed_spec.rb
|
@@ -158,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
130
|
version: '0'
|
159
131
|
requirements: []
|
160
132
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.2.2
|
162
134
|
signing_key:
|
163
135
|
specification_version: 4
|
164
136
|
summary: RSpec for Sidekiq
|