rspec-sidekiq 3.0.1 → 3.0.2

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: 6ba307301b01ff432ddf0af3a8cbb8ec6e964841
4
- data.tar.gz: 63c7be8e00350bbf61a3c33827d882cba90c13f3
3
+ metadata.gz: e6649639a5e74b4ef9f3693f45a01fb739e335c9
4
+ data.tar.gz: 2dc425b4dff7f7426a8273827f99649c02dffc5d
5
5
  SHA512:
6
- metadata.gz: cfd1b9391aed34b66dfda591a88c95a6bfc0d5a06050bcef9bdca11d8d3a6fb2f99a68cd1a2040f180d9bbce41c01135343a1920db47d59e58864c8259de6fa8
7
- data.tar.gz: 6b3ec3ca8c7caab2cbe270600f7b5312b039f7a213453630ab2c590854e102c8a9b9f611d6ff8d8fb11e8b36285c638591e6ff82fc5fcad2b1e6cf4162be2e1b
6
+ metadata.gz: 8d5049aa45f152d9a0800db686c9a5a40cc01aec66a9e60c97d2ce9cde572aa62b45270f767b4e7a5834067f01890ae428149b1ae4e66c13e456842d2c9c9b53
7
+ data.tar.gz: 4128b29a64d24c20532f35f9944c4c873f681e94b84c2a0b958a2ece53adf0ce28e7164a63f6738c7ac0a6bf3c52898ef0fffaaeb4d5106e566d2b87a4c8b9fa
data/README.md CHANGED
@@ -52,7 +52,7 @@ end
52
52
  * [be_processed_in](#be_processed_in)
53
53
  * [be_retryable](#be_retryable)
54
54
  * [be_unique](#be_unique)
55
- * [have_enqueued_job](#have_enqueued_job)
55
+ * [have_enqueued_sidekiq_job](#have_enqueued_sidekiq_job)
56
56
 
57
57
  ### be_delayed
58
58
  *Describes a method that should be invoked asynchronously (See [Sidekiq Delayed Extensions][sidekiq_wiki_delayed_extensions])*
@@ -136,11 +136,19 @@ 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_job
139
+ ### have_enqueued__sidekiq_job
140
140
  *Describes that there should be an enqueued job with the specified arguments*
141
+
142
+ **Note:** When using rspec-rails >= 3.4, use `have_enqueued_sidekiq_job` instead to
143
+ prevent a name clash with rspec-rails' ActiveJob matcher.
144
+
141
145
  ```ruby
142
146
  AwesomeJob.perform_async 'Awesome', true
143
147
  # test with...
148
+ expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true)
149
+
150
+ # Code written with older versions of the gem may use the deprecated
151
+ # have_enqueued_job matcher.
144
152
  expect(AwesomeJob).to have_enqueued_job('Awesome', true)
145
153
  ```
146
154
 
@@ -149,12 +157,12 @@ expect(AwesomeJob).to have_enqueued_job('Awesome', true)
149
157
  ```ruby
150
158
  Awesomejob.perform_at 5.minutes.from_now, 'Awesome', true
151
159
  # test with...
152
- expect(AwesomeJob).to have_enqueued_job('Awesome', true).at(5.minutes.from_now)
160
+ expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).at(5.minutes.from_now)
153
161
  ```
154
162
  ```ruby
155
163
  Awesomejob.perform_in 5.minutes, 'Awesome', true
156
164
  # test with...
157
- expect(AwesomeJob).to have_enqueued_job('Awesome', true).in(5.minutes)
165
+ expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).in(5.minutes)
158
166
  ```
159
167
 
160
168
  ## Example matcher usage
@@ -170,7 +178,7 @@ describe AwesomeJob do
170
178
  it 'enqueues another awesome job' do
171
179
  subject.perform
172
180
 
173
- expect(AnotherAwesomeJob).to have_enqueued_job('Awesome', true)
181
+ expect(AnotherAwesomeJob).to have_enqueued_sidekiq_job('Awesome', true)
174
182
  end
175
183
  end
176
184
  ```
@@ -11,7 +11,7 @@ module RSpec
11
11
  end
12
12
 
13
13
  def description
14
- if @expected_retry.is_a?(Fixnum)
14
+ if @expected_retry.is_a?(Numeric)
15
15
  "retry #{@expected_retry} times" # retry: 5
16
16
  elsif @expected_retry
17
17
  'retry the default number of times' # retry: true
@@ -1,13 +1,13 @@
1
1
  module RSpec
2
2
  module Sidekiq
3
3
  module Matchers
4
- def have_enqueued_job(*expected_arguments)
4
+ def have_enqueued_sidekiq_job(*expected_arguments)
5
5
  HaveEnqueuedJob.new expected_arguments
6
6
  end
7
7
 
8
- if Gem::Dependency.new('rspec-rails', '>= 3.4.0').matching_specs.max_by(&:version)
8
+ def have_enqueued_job(*expected_arguments)
9
9
  warn "[DEPRECATION] `have_enqueued_job` is deprecated. Please use `have_enqueued_sidekiq_job` instead."
10
- alias have_enqueued_sidekiq_job have_enqueued_job
10
+ have_enqueued_sidekiq_job(expected_arguments)
11
11
  end
12
12
 
13
13
  class JobOptionParser
@@ -11,7 +11,7 @@ module RSpec
11
11
  end
12
12
 
13
13
  def description
14
- if @expected_backtrace.is_a?(Fixnum)
14
+ if @expected_backtrace.is_a?(Numeric)
15
15
  "save #{@expected_backtrace} lines of error backtrace" # backtrace: 5
16
16
  elsif @expected_backtrace
17
17
  'save error backtrace' # backtrace: true
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Sidekiq
3
- VERSION = '3.0.1'
3
+ VERSION = '3.0.2'
4
4
  end
5
5
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency 'fuubar', '~> 2.0', '>= 2.0.0'
20
20
  s.add_development_dependency 'activejob', '~> 4.2', '>= 4.0.0'
21
21
  s.add_development_dependency 'actionmailer', '~> 4.2', '>= 4.0.0'
22
+ s.add_development_dependency 'activerecord', '~> 4.2', '>= 4.0.0'
22
23
 
23
24
 
24
25
  s.files = Dir['.gitattributes'] +
@@ -21,11 +21,11 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
21
21
  describe 'expected usage' do
22
22
  context 'Sidekiq' do
23
23
  it 'matches' do
24
- expect(worker).to have_enqueued_job *worker_args
24
+ expect(worker).to have_enqueued_sidekiq_job *worker_args
25
25
  end
26
26
 
27
27
  it 'matches on the global Worker queue' do
28
- expect(Sidekiq::Worker).to have_enqueued_job *worker_args
28
+ expect(Sidekiq::Worker).to have_enqueued_sidekiq_job *worker_args
29
29
  end
30
30
 
31
31
  context 'perform_in' do
@@ -36,7 +36,7 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
36
36
  end
37
37
 
38
38
  it 'matches on an scheduled job with #perform_in' do
39
- expect(worker).to have_enqueued_job(*worker_args_in).in(interval)
39
+ expect(worker).to have_enqueued_sidekiq_job(*worker_args_in).in(interval)
40
40
  end
41
41
  end
42
42
 
@@ -48,24 +48,24 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
48
48
  end
49
49
 
50
50
  it 'matches on an scheduled job with #perform_at' do
51
- expect(worker).to have_enqueued_job(*worker_args_at).at(tomorrow)
51
+ expect(worker).to have_enqueued_sidekiq_job(*worker_args_at).at(tomorrow)
52
52
  end
53
53
  end
54
54
  end
55
55
 
56
56
  context 'ActiveJob' do
57
57
  it 'matches on an enqueued ActiveJob' do
58
- expect(Sidekiq::Worker).to have_enqueued_job 'someResource'
58
+ expect(Sidekiq::Worker).to have_enqueued_sidekiq_job 'someResource'
59
59
  end
60
60
 
61
61
  it 'matches on an enqueued ActiveJob by global_id' do
62
- expect(Sidekiq::Worker).to have_enqueued_job('_aj_globalid' => resource.to_global_id.uri.to_s)
62
+ expect(Sidekiq::Worker).to have_enqueued_sidekiq_job('_aj_globalid' => resource.to_global_id.uri.to_s)
63
63
  end
64
64
  end
65
65
 
66
66
  context 'ActionMailer' do
67
67
  it 'matches on ActionMailer Job' do
68
- expect(Sidekiq::Worker).to have_enqueued_job(
68
+ expect(Sidekiq::Worker).to have_enqueued_sidekiq_job(
69
69
  'TestActionMailer',
70
70
  'testmail',
71
71
  'deliver_now'
@@ -73,7 +73,7 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
73
73
  end
74
74
 
75
75
  it 'matches on ActionMailer with a resource Job' do
76
- expect(Sidekiq::Worker).to have_enqueued_job(
76
+ expect(Sidekiq::Worker).to have_enqueued_sidekiq_job(
77
77
  'TestActionMailer',
78
78
  'testmail',
79
79
  'deliver_now',
@@ -83,10 +83,20 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
83
83
  end
84
84
  end
85
85
 
86
+ describe '#have_enqueued_sidekiq_job' do
87
+ it 'returns instance' do
88
+ expect(have_enqueued_sidekiq_job).to be_a RSpec::Sidekiq::Matchers::HaveEnqueuedJob
89
+ end
90
+ end
91
+
86
92
  describe '#have_enqueued_job' do
87
93
  it 'returns instance' do
88
94
  expect(have_enqueued_job).to be_a RSpec::Sidekiq::Matchers::HaveEnqueuedJob
89
95
  end
96
+
97
+ it 'provides deprecation warning' do
98
+ expect { have_enqueued_job }.to output(/[DEPRECATION]/).to_stderr
99
+ end
90
100
  end
91
101
 
92
102
  describe '#description' do
@@ -9,10 +9,9 @@ require 'action_mailer'
9
9
 
10
10
  require_relative 'support/init'
11
11
 
12
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
13
- Coveralls::SimpleCov::Formatter,
14
- SimpleCov::Formatter::HTMLFormatter
15
- ]
12
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
13
+ [Coveralls::SimpleCov::Formatter, SimpleCov::Formatter::HTMLFormatter]
14
+ )
16
15
  SimpleCov.start
17
16
 
18
17
  RSpec.configure do |config|
@@ -22,3 +21,9 @@ RSpec.configure do |config|
22
21
  end
23
22
 
24
23
  ActiveJob::Base.queue_adapter = :sidekiq
24
+
25
+ if Gem::Dependency.new('sidekiq', '>= 5.0.0').matching_specs.any?
26
+ require 'active_record'
27
+ ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
28
+ Sidekiq::Extensions.enable_delay!
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
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-04-10 00:00:00.000000000 Z
11
+ date: 2017-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core
@@ -138,6 +138,26 @@ dependencies:
138
138
  - - ">="
139
139
  - !ruby/object:Gem::Version
140
140
  version: 4.0.0
141
+ - !ruby/object:Gem::Dependency
142
+ name: activerecord
143
+ requirement: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: '4.2'
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: 4.0.0
151
+ type: :development
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '4.2'
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: 4.0.0
141
161
  description: Simple testing of Sidekiq jobs via a collection of matchers and helpers
142
162
  email: github@philostler.com
143
163
  executables: []
@@ -178,7 +198,6 @@ files:
178
198
  - spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb
179
199
  - spec/rspec/sidekiq/matchers/save_backtrace_spec.rb
180
200
  - spec/rspec/sidekiq/sidekiq_spec.rb
181
- - spec/rspec/sidekiq/version_spec.rb
182
201
  - spec/spec_helper.rb
183
202
  - spec/support/factories.rb
184
203
  - spec/support/init.rb
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe RSpec::Sidekiq::VERSION do
4
- it { is_expected.to eq('3.0.1') }
5
- end