rspec-sidekiq 3.0.3 → 3.1.0

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
- SHA1:
3
- metadata.gz: dd244416f99c35639675efb4b3473dd9741d512c
4
- data.tar.gz: 6fa5eb3e029086fe4d316a6a9896b7acddb834de
2
+ SHA256:
3
+ metadata.gz: 9521e2acad8dae8dc1c47afeb1a3f4f1052f44d2d512ae29866548f5cefdbb61
4
+ data.tar.gz: 4ce5c1b0a18cec884a1b023ae113f3e692afcc471c9e2dd067c762d6051a77d5
5
5
  SHA512:
6
- metadata.gz: fe360471b5c79f74e4af320881d97d0d26ec0cf837a8309e8b898221d71c63bce2d2a750d32b9427dfb931dc4a83837e4c2e3e6b1ddd6a5ed17050205f7e4aa3
7
- data.tar.gz: 1d0913303fbdd4c72aea0248e815d4842a5c8fe9d0a338c6cad7cf0dbd59fc7145899718d51185444c72023772605e30099326c8481345927f083c9db91df7e6
6
+ metadata.gz: e3501020bc4f14f5294b1cb67483c3018f608111e4c50ec74c193927e0dadf41ad7532e5c2a695f7d107cd435094eb59751ab23743f6b97a316059f8cc77ba7f
7
+ data.tar.gz: 79003f53fa67a71b288a2de8d35bdc65aeb123e5dedf929e8012cff2e999aadaa5f3830d9d4dc33889ff4a270adbf9b1045a81e0b7372882b577e8d9553e8e9c
data/CHANGES.md CHANGED
@@ -1,3 +1,12 @@
1
+ 3.1.0
2
+ ---
3
+ * Add support for latest ruby and Rails 5 (coding-bunny #156)
4
+ * Support `Class#method` notation in batch callback (caalberts #155)
5
+ * Fix bug with time comparison in delayed jobs (geeosh #153 with help from col)
6
+ * remove usage of `Integer#blank?` (lanej #152)
7
+ * Add `NullBatch#description` (dsantosmerino #139)
8
+ * README updates (BenMusch #142, akihikodaki #141, wpolicarpo #160)
9
+
1
10
  3.0.3
2
11
  ---
3
12
  * Re-splat arguments for the have_enqueued_job alias (aprescott #136)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- **Welcome @wpolicarpo and @packrat386 as new maintainers for `rspec-sidekiq`!**
1
+ **Welcome @packrat386 as new maintainer for `rspec-sidekiq`!**
2
2
 
3
3
  # RSpec for Sidekiq
4
4
 
@@ -87,7 +87,7 @@ it { is_expected.to be_processed_in :download }
87
87
  ```
88
88
 
89
89
  ### be_retryable
90
- *Describes if a job should retry when there is a failure in it's execution*
90
+ *Describes if a job should retry when there is a failure in its execution*
91
91
  ```ruby
92
92
  sidekiq_options retry: 5
93
93
  # test with...
@@ -102,7 +102,7 @@ it { is_expected.to be_retryable false }
102
102
  ```
103
103
 
104
104
  ### save_backtrace
105
- *Describes if a job should save the error backtrace when there is a failure in it's execution*
105
+ *Describes if a job should save the error backtrace when there is a failure in its execution*
106
106
  ```ruby
107
107
  sidekiq_options backtrace: 5
108
108
  # test with...
@@ -119,7 +119,7 @@ it { is_expected.to save_backtrace false }
119
119
  ```
120
120
 
121
121
  ### be_unique
122
- *Describes when a job should be unique within it's queue*
122
+ *Describes when a job should be unique within its queue*
123
123
  ```ruby
124
124
  sidekiq_options unique: true
125
125
  # test with...
@@ -136,7 +136,7 @@ it { is_expected.to be_expired_in 1.hour }
136
136
  it { is_expected.to_not be_expired_in 2.hours }
137
137
  ```
138
138
 
139
- ### have_enqueued__sidekiq_job
139
+ ### have_enqueued_sidekiq_job
140
140
  *Describes that there should be an enqueued job with the specified arguments*
141
141
 
142
142
  **Note:** When using rspec-rails >= 3.4, use `have_enqueued_sidekiq_job` instead to
@@ -155,9 +155,10 @@ expect(AwesomeJob).to have_enqueued_job('Awesome', true)
155
155
  #### Testing scheduled jobs
156
156
  *Use chainable matchers `#at` and `#in`*
157
157
  ```ruby
158
- Awesomejob.perform_at 5.minutes.from_now, 'Awesome', true
158
+ time = 5.minutes.from_now
159
+ Awesomejob.perform_at time, 'Awesome', true
159
160
  # test with...
160
- expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).at(5.minutes.from_now)
161
+ expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).at(time)
161
162
  ```
162
163
  ```ruby
163
164
  Awesomejob.perform_in 5.minutes, 'Awesome', true
@@ -205,7 +206,6 @@ FooClass.within_sidekiq_retries_exhausted_block {
205
206
  ```bundle exec rspec spec```
206
207
 
207
208
  ## Maintainers
208
- * @wpolicarpo
209
209
  * @packrat386
210
210
  * @philostler
211
211
 
@@ -10,6 +10,7 @@ if defined? Sidekiq::Batch
10
10
  end
11
11
 
12
12
  class NullBatch < NullObject
13
+ attr_accessor :description
13
14
  attr_reader :bid
14
15
 
15
16
  def initialize(bid = nil)
@@ -45,9 +46,17 @@ if defined? Sidekiq::Batch
45
46
  def join
46
47
  ::Sidekiq::Worker.drain_all
47
48
 
48
- @callbacks.each do |event, callback_class, options|
49
+ @callbacks.each do |event, callback, options|
49
50
  if event != :success || failures == 0
50
- callback_class.new.send("on_#{event}", self, options)
51
+ case callback
52
+ when Class
53
+ callback.new.send("on_#{event}", self, options)
54
+ when String
55
+ klass, meth = callback.split('#')
56
+ klass.constantize.new.send(meth, self, options)
57
+ else
58
+ raise ArgumentError, 'Unsupported callback notation'
59
+ end
51
60
  end
52
61
  end
53
62
  end
@@ -25,13 +25,13 @@ module RSpec
25
25
  private
26
26
 
27
27
  def at_evaluator(value)
28
- return false if job['at'].blank?
29
- value.to_time.to_s == Time.at(job['at']).to_s
28
+ return false if job['at'].to_s.empty?
29
+ value.to_time.to_i == Time.at(job['at']).to_i
30
30
  end
31
31
 
32
32
  def in_evaluator(value)
33
- return false if job['at'].blank?
34
- (Time.now + value).to_s == Time.at(job['at']).to_s
33
+ return false if job['at'].to_s.empty?
34
+ (Time.now + value).to_i == Time.at(job['at']).to_i
35
35
  end
36
36
  end
37
37
 
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Sidekiq
3
- VERSION = '3.0.3'
3
+ VERSION = '3.1.0'
4
4
  end
5
5
  end
@@ -14,12 +14,14 @@ Gem::Specification.new do |s|
14
14
  s.add_dependency 'rspec-core', '~> 3.0', '>= 3.0.0'
15
15
  s.add_dependency 'sidekiq', '>= 2.4.0'
16
16
 
17
- s.add_development_dependency 'rspec', '~> 3.0'
18
- s.add_development_dependency 'coveralls', '~> 0.8', '>= 0.8.0'
19
- s.add_development_dependency 'fuubar', '~> 2.0', '>= 2.0.0'
20
- s.add_development_dependency 'activejob', '~> 4.2', '>= 4.0.0'
21
- s.add_development_dependency 'actionmailer', '~> 4.2', '>= 4.0.0'
22
- s.add_development_dependency 'activerecord', '~> 4.2', '>= 4.0.0'
17
+ s.add_development_dependency 'rspec'
18
+ s.add_development_dependency 'coveralls'
19
+ s.add_development_dependency 'fuubar'
20
+ s.add_development_dependency 'activejob'
21
+ s.add_development_dependency 'actionmailer'
22
+ s.add_development_dependency 'activerecord'
23
+ s.add_development_dependency 'activemodel'
24
+ s.add_development_dependency 'activesupport'
23
25
 
24
26
 
25
27
  s.files = Dir['.gitattributes'] +
@@ -58,12 +58,18 @@ RSpec.describe 'Batch' do
58
58
  def on_event(status, options); end
59
59
  end
60
60
 
61
+ class OtherCallback
62
+ def foo(status, options); end
63
+ end
64
+
61
65
  before(:each) do
62
66
  batch.on(:event, MyCallback, my_arg: 42)
67
+ batch.on(:event, 'OtherCallback#foo', my_arg: 23)
63
68
  end
64
69
 
65
70
  it 'executes callbacks' do
66
71
  expect_any_instance_of(MyCallback).to receive(:on_event).with(subject, { my_arg: 42 })
72
+ expect_any_instance_of(OtherCallback).to receive(:foo).with(subject, { my_arg: 23 })
67
73
  subject.join
68
74
  end
69
75
  end
@@ -108,7 +108,7 @@ RSpec.describe RSpec::Sidekiq::Matchers::BeUnique do
108
108
 
109
109
  context "without a uniquing solution" do
110
110
  it "raises an exception" do
111
- expect{subject.unique_key}.to raise_error
111
+ expect{subject.unique_key}.to raise_error RuntimeError, 'No support found for Sidekiq unique jobs'
112
112
  end
113
113
  end
114
114
  end
@@ -4,13 +4,14 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
4
4
  let(:tomorrow) { DateTime.now + 1 }
5
5
  let(:interval) { 3.minutes }
6
6
  let(:argument_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new worker_args }
7
- let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(Fixnum), true, be_a(Hash)] }
7
+ let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(Integer), true, be_a(Hash)] }
8
8
  let(:worker) { create_worker }
9
9
  let(:worker_args) { ['string', 1, true, { key: 'value', bar: :foo, nested: [{hash: true}] }] }
10
10
  let(:active_job) { create_active_job :mailers }
11
11
  let(:resource) { TestResource.new }
12
12
 
13
13
  before(:each) do
14
+ GlobalID.app = 'rspec-sidekiq'
14
15
  worker.perform_async *worker_args
15
16
  active_job.perform_later 'someResource'
16
17
  active_job.perform_later(resource)
@@ -1,16 +1,10 @@
1
1
  class TestResource
2
2
  include GlobalID::Identification
3
3
 
4
- attr_reader :global_id
5
-
6
- def initialize
7
- @global_id = GlobalID.create(self, { app: 'rspec-sidekiq' })
8
- end
9
-
10
4
  def self.find(id)
11
5
  end
12
6
 
13
7
  def id
14
- rand(36**10).to_s 36
8
+ @id ||= rand(36**10).to_s 36
15
9
  end
16
10
  end
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.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: 2017-06-23 00:00:00.000000000 Z
11
+ date: 2020-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '3.0'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
19
  version: 3.0.0
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '3.0'
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
29
  version: 3.0.0
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: sidekiq
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -48,116 +48,114 @@ dependencies:
48
48
  name: rspec
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '3.0'
53
+ version: '0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '3.0'
60
+ version: '0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: coveralls
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '0.8'
68
65
  - - ">="
69
66
  - !ruby/object:Gem::Version
70
- version: 0.8.0
67
+ version: '0'
71
68
  type: :development
72
69
  prerelease: false
73
70
  version_requirements: !ruby/object:Gem::Requirement
74
71
  requirements:
75
- - - "~>"
76
- - !ruby/object:Gem::Version
77
- version: '0.8'
78
72
  - - ">="
79
73
  - !ruby/object:Gem::Version
80
- version: 0.8.0
74
+ version: '0'
81
75
  - !ruby/object:Gem::Dependency
82
76
  name: fuubar
83
77
  requirement: !ruby/object:Gem::Requirement
84
78
  requirements:
85
- - - "~>"
86
- - !ruby/object:Gem::Version
87
- version: '2.0'
88
79
  - - ">="
89
80
  - !ruby/object:Gem::Version
90
- version: 2.0.0
81
+ version: '0'
91
82
  type: :development
92
83
  prerelease: false
93
84
  version_requirements: !ruby/object:Gem::Requirement
94
85
  requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: '2.0'
98
86
  - - ">="
99
87
  - !ruby/object:Gem::Version
100
- version: 2.0.0
88
+ version: '0'
101
89
  - !ruby/object:Gem::Dependency
102
90
  name: activejob
103
91
  requirement: !ruby/object:Gem::Requirement
104
92
  requirements:
105
- - - "~>"
106
- - !ruby/object:Gem::Version
107
- version: '4.2'
108
93
  - - ">="
109
94
  - !ruby/object:Gem::Version
110
- version: 4.0.0
95
+ version: '0'
111
96
  type: :development
112
97
  prerelease: false
113
98
  version_requirements: !ruby/object:Gem::Requirement
114
99
  requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '4.2'
118
100
  - - ">="
119
101
  - !ruby/object:Gem::Version
120
- version: 4.0.0
102
+ version: '0'
121
103
  - !ruby/object:Gem::Dependency
122
104
  name: actionmailer
123
105
  requirement: !ruby/object:Gem::Requirement
124
106
  requirements:
125
- - - "~>"
126
- - !ruby/object:Gem::Version
127
- version: '4.2'
128
107
  - - ">="
129
108
  - !ruby/object:Gem::Version
130
- version: 4.0.0
109
+ version: '0'
131
110
  type: :development
132
111
  prerelease: false
133
112
  version_requirements: !ruby/object:Gem::Requirement
134
113
  requirements:
135
- - - "~>"
136
- - !ruby/object:Gem::Version
137
- version: '4.2'
138
114
  - - ">="
139
115
  - !ruby/object:Gem::Version
140
- version: 4.0.0
116
+ version: '0'
141
117
  - !ruby/object:Gem::Dependency
142
118
  name: activerecord
143
119
  requirement: !ruby/object:Gem::Requirement
144
120
  requirements:
145
- - - "~>"
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
146
129
  - !ruby/object:Gem::Version
147
- version: '4.2'
130
+ version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: activemodel
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
148
135
  - - ">="
149
136
  - !ruby/object:Gem::Version
150
- version: 4.0.0
137
+ version: '0'
151
138
  type: :development
152
139
  prerelease: false
153
140
  version_requirements: !ruby/object:Gem::Requirement
154
141
  requirements:
155
- - - "~>"
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: activesupport
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
156
150
  - !ruby/object:Gem::Version
157
- version: '4.2'
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
158
156
  - - ">="
159
157
  - !ruby/object:Gem::Version
160
- version: 4.0.0
158
+ version: '0'
161
159
  description: Simple testing of Sidekiq jobs via a collection of matchers and helpers
162
160
  email: github@philostler.com
163
161
  executables: []
@@ -225,8 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
223
  - !ruby/object:Gem::Version
226
224
  version: '0'
227
225
  requirements: []
228
- rubyforge_project:
229
- rubygems_version: 2.5.2
226
+ rubygems_version: 3.0.3
230
227
  signing_key:
231
228
  specification_version: 4
232
229
  summary: RSpec for Sidekiq