rspec-sidekiq 0.5.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +9 -9
  2. data/.gitattributes +22 -22
  3. data/.gitignore +1 -1
  4. data/.rspec +2 -2
  5. data/.simplecov +5 -0
  6. data/CHANGES.md +52 -35
  7. data/Gemfile +8 -2
  8. data/LICENSE +8 -8
  9. data/README.md +181 -135
  10. data/lib/rspec/sidekiq/batch.rb +46 -43
  11. data/lib/rspec/sidekiq/configuration.rb +12 -10
  12. data/lib/rspec/sidekiq/helpers/within_sidekiq_retries_exhausted_block.rb +11 -0
  13. data/lib/rspec/sidekiq/helpers.rb +2 -0
  14. data/lib/rspec/sidekiq/matchers/be_delayed.rb +67 -0
  15. data/lib/rspec/sidekiq/matchers/be_processed_in.rb +32 -32
  16. data/lib/rspec/sidekiq/matchers/be_retryable.rb +38 -38
  17. data/lib/rspec/sidekiq/matchers/be_unique.rb +28 -28
  18. data/lib/rspec/sidekiq/matchers/have_enqueued_job.rb +33 -33
  19. data/lib/rspec/sidekiq/matchers/have_enqueued_jobs.rb +11 -36
  20. data/lib/rspec/sidekiq/matchers.rb +10 -9
  21. data/lib/rspec/sidekiq/sidekiq.rb +24 -20
  22. data/lib/rspec/sidekiq/version.rb +4 -4
  23. data/lib/rspec-sidekiq.rb +7 -6
  24. data/rspec-sidekiq.gemspec +35 -34
  25. data/spec/rspec/sidekiq/batch_spec.rb +27 -0
  26. data/spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb +18 -0
  27. data/spec/rspec/sidekiq/matchers/be_delayed_spec.rb +238 -0
  28. data/spec/rspec/sidekiq/matchers/be_processed_in_spec.rb +107 -28
  29. data/spec/rspec/sidekiq/matchers/be_retryable_spec.rb +128 -40
  30. data/spec/rspec/sidekiq/matchers/be_unique_spec.rb +49 -14
  31. data/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb +73 -0
  32. data/spec/rspec/sidekiq/matchers/have_enqueued_jobs_spec.rb +9 -0
  33. data/spec/rspec/sidekiq/sidekiq_spec.rb +15 -0
  34. data/spec/rspec/sidekiq/version_spec.rb +4 -6
  35. data/spec/spec_helper.rb +27 -25
  36. data/spec/support/factories.rb +22 -0
  37. data/spec/support/init.rb +3 -3
  38. data/spec/support/test_worker.rb +7 -7
  39. data/spec/support/test_worker_alternative.rb +7 -7
  40. metadata +29 -21
  41. data/spec/support/test_worker_defaults.rb +0 -6
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjNmMWRlZTNlNDJkYTllMDg1YWRkZGRmMTBhNjIyNjA2NTAyZGNhNQ==
4
+ MjNiZmI2MTNlM2Q2ZDBjOTlmYTU4NTliYzlkZDUyODY0Y2RiNmE0Mw==
5
5
  data.tar.gz: !binary |-
6
- M2NjNzkyMTk4ZWZjYTVlN2I3MTQ2YzYzMjdjMDJjOTUxNzIzMjBiOQ==
7
- !binary "U0hBNTEy":
6
+ YzlmNjA3MjViZDdhNDhkMWM2Y2FiZjBiZjNlNmE3YzI3Yjk0MTk2OA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- NDVhZjc3NzFkNDM4NjNhYmZiNTdiMzc1MDQ2YTY0YTQ1Mzc5MjE1ZmZjZWM2
10
- MjRmNmQ1MjVhOGJhMzQ5NGY5Y2ZmYTZhYTY2ZjE4ODA5MzFhOWMzNzQ3YzY0
11
- ZTVkZTY4ZjAxZTAwYWQ0NDczNzFjNWJiYmMzMzExNTczYTdjMmM=
9
+ NWE0YjVkYmE5YjZkZGZlNmIyN2JkNDdlNjNlZDE0MWI5NDY1ZGUxZTZmYzE3
10
+ YTMyZWM1MGY0YTkwNWI1YTBkN2E3MmQwNmU5ZjRlMGY4YTgyYjUxOGI2Nzkx
11
+ MDJhNjgyMGZkYmRkMDViODE0M2Y1Yzg1MTFkMzZkYjRhYTFjOWY=
12
12
  data.tar.gz: !binary |-
13
- M2U1NmQ1NjZlMGZhYzE1MDZjYjc1MzhiYjE2ZGQxNTNmNmNlZGRhNzNiYTE1
14
- NjYxZTQ1MjM4MjBjNzc3MmNlMTlkODEwNGU3MGE5MDk1MWM1ZDQ3ZTRmNGQ3
15
- YTcxOWMxMmMzZWRhNjcyNzQ2Y2M2NmM1YjAzNzg0NGUzYWI1MzI=
13
+ N2I3M2Y1ODZmYjY4YTA0MGVhYWM5ODhlNTU3YjBjYTQ5ZDcxYzdlNjM4NmM4
14
+ ODg3OTVjNzZmOTFiYzc4NTNjZWZhMThjZjZkOGIwMTk5MDM5YzVlY2JiZjE3
15
+ ZGU0ODYwMjBiODc0YmE0MDFhZTllYjZiNWNkNzYxZjhhNDMzMDc=
data/.gitattributes CHANGED
@@ -1,22 +1,22 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
3
-
4
- # Custom for Visual Studio
5
- *.cs diff=csharp
6
- *.sln merge=union
7
- *.csproj merge=union
8
- *.vbproj merge=union
9
- *.fsproj merge=union
10
- *.dbproj merge=union
11
-
12
- # Standard to msysgit
13
- *.doc diff=astextplain
14
- *.DOC diff=astextplain
15
- *.docx diff=astextplain
16
- *.DOCX diff=astextplain
17
- *.dot diff=astextplain
18
- *.DOT diff=astextplain
19
- *.pdf diff=astextplain
20
- *.PDF diff=astextplain
21
- *.rtf diff=astextplain
22
- *.RTF diff=astextplain
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
3
+
4
+ # Custom for Visual Studio
5
+ *.cs diff=csharp
6
+ *.sln merge=union
7
+ *.csproj merge=union
8
+ *.vbproj merge=union
9
+ *.fsproj merge=union
10
+ *.dbproj merge=union
11
+
12
+ # Standard to msysgit
13
+ *.doc diff=astextplain
14
+ *.DOC diff=astextplain
15
+ *.docx diff=astextplain
16
+ *.DOCX diff=astextplain
17
+ *.dot diff=astextplain
18
+ *.DOT diff=astextplain
19
+ *.pdf diff=astextplain
20
+ *.PDF diff=astextplain
21
+ *.rtf diff=astextplain
22
+ *.RTF diff=astextplain
data/.gitignore CHANGED
@@ -1,2 +1,2 @@
1
- Gemfile.lock
1
+ Gemfile.lock
2
2
  spec_result
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --colour
2
- --format Fuubar
1
+ --colour
2
+ --format Fuubar
3
3
  --format html --out spec_result/rspec.html
data/.simplecov ADDED
@@ -0,0 +1,5 @@
1
+ SimpleCov.start do
2
+ add_filter "/spec/"
3
+
4
+ coverage_dir "spec_result"
5
+ end
data/CHANGES.md CHANGED
@@ -1,35 +1,52 @@
1
- 0.5.1
2
- ---
3
- * Allows Sidekiq::Batch support to work with Mocha as well RSpec stubbing [noiseunion#20]
4
-
5
- 0.5.0
6
- ---
7
- * Adds stub support for Sidekiq::Batch [kmayer#17]
8
-
9
- 0.4.0
10
- ---
11
- * Bug fix for matcher failure if sidekiq_options were defined as strings vs symbols [mhuffnagle#16 & philostler]
12
- * Matcher tests (partial coverage) added [mhuffnagle#16 & philostler]
13
-
14
- 0.3.0
15
- ---
16
- * Removed restriction on needing to use sidekiq-middleware with be_unique matcher [philostler#4]
17
- * Ensure RSpec.configure is defined on loading rspec/sidekiq/matchers [centaure#3]
18
-
19
- 0.2.2
20
- ---
21
- * Matcher ```be_retryable false``` not producing correct output description [philostler]
22
-
23
- 0.2.1
24
- ---
25
- * Removed debug #puts [philostler]
26
-
27
- 0.2.0
28
- ---
29
- * New #have_enqueued_job matcher [philostler]
30
- * Improved #have_enqueued_jobs description [philostler]
31
- * Minor documentation updates [philostler]
32
-
33
- 0.1.0
34
- ---
35
- * Initial release [philostler]
1
+ 1.0.0
2
+ ---
3
+ * Improve coverage and readability of README [philostler#26]
4
+ * Greatly increase test coverage [philostler#27]
5
+ * Refactor and greatly improve be_a_delayed_job matcher (now be_delayed) [philostler#24 & #25]
6
+ * Add implementation of status.total [matthargett & Kelly Felkins#32 & #39]
7
+ * Fix Rubinius build [petergoldstein#38]
8
+ * Remove have_enqueued_jobs matcher [philostler#37]
9
+ * Travis - Ruby 2.1.0, fix Rubinius build [petergoldstein#35]
10
+ * Prepare for RSpec 3.x [petergoldstein#34]
11
+ * Print warning when used in development mode [mperham & philostler#33]
12
+ * Add helper for testing retries exhausted block [Noreaster76#31]
13
+ * Allow to use [general matchers](https://www.relishapp.com/rspec/rspec-mocks/v/2-14/docs/argument-matchers/general-matchers) in have_enqueued_job [johanneswuerbach#30]
14
+ * Loosen RSpec dependency [philostler#23]
15
+ * Add delay extension matchers [sosaucily#22]
16
+ * Update coveralls development dependency to version 0.7.x [philostler]
17
+
18
+ 0.5.1
19
+ ---
20
+ * Allows Sidekiq::Batch support to work with Mocha as well RSpec stubbing [noiseunion#20]
21
+
22
+ 0.5.0
23
+ ---
24
+ * Adds stub support for Sidekiq::Batch [kmayer#17]
25
+
26
+ 0.4.0
27
+ ---
28
+ * Bug fix for matcher failure if sidekiq_options were defined as strings vs symbols [mhuffnagle#16 & philostler]
29
+ * Matcher tests (partial coverage) added [mhuffnagle#16 & philostler]
30
+
31
+ 0.3.0
32
+ ---
33
+ * Removed restriction on needing to use sidekiq-middleware with be_unique matcher [philostler#4]
34
+ * Ensure RSpec.configure is defined on loading rspec/sidekiq/matchers [centaure#3]
35
+
36
+ 0.2.2
37
+ ---
38
+ * Matcher ```be_retryable false``` not producing correct output description [philostler]
39
+
40
+ 0.2.1
41
+ ---
42
+ * Removed debug #puts [philostler]
43
+
44
+ 0.2.0
45
+ ---
46
+ * New #have_enqueued_job matcher [philostler]
47
+ * Improved #have_enqueued_jobs description [philostler]
48
+ * Minor documentation updates [philostler]
49
+
50
+ 0.1.0
51
+ ---
52
+ * Initial release [philostler]
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
- source "https://rubygems.org"
2
-
1
+ source "https://rubygems.org"
2
+
3
+ platforms :rbx do
4
+ gem "rubysl", "~> 2.0"
5
+ gem "psych"
6
+ gem "rubinius-developer_tools"
7
+ end
8
+
3
9
  gemspec
data/LICENSE CHANGED
@@ -1,9 +1,9 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2013 Phil Ostler
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Phil Ostler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
9
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,135 +1,181 @@
1
- # RSpec for Sidekiq
2
-
3
- [![RubyGems][gem_version_badge]][ruby_gems]
4
- [![Code Climate][code_climate_badge]][code_climate]
5
- [![Travis CI][travis_ci_badge]][travis_ci]
6
- [![Coveralls][coveralls_badge]][coveralls]
7
- [![Gemnasium][gemnasium_badge]][gemnasium]
8
- [![coderwall][coderwall_badge]][coderwall]
9
-
10
- *Simple testing of Sidekiq jobs via a collection of matchers and common tasks*
11
-
12
- [RubyGems][ruby_gems] |
13
- [Code Climate][code_climate] |
14
- [GitHub][github] |
15
- [Travis CI][travis_ci] |
16
- [Coveralls][coveralls] |
17
- [Gemnasium][gemnasium] |
18
- [RubyDoc][ruby_doc] |
19
- [Ruby Toolbox][ruby_toolbox]
20
-
21
- ## Installation
22
- ```ruby
23
- # Gemfile
24
- group :test do
25
- gem "rspec-sidekiq"
26
- end
27
- ```
28
- ```rspec-sidekiq``` requires ```sidekiq/testing``` by default so there is no need to include the line ```require "sidekiq/testing"``` inside your ```spec_helper.rb```.
29
-
30
- *This has the effect of not pushing enqueued jobs to Redis but to a ```job``` array to enable testing ([see Sidekiq's testing wiki](https://github.com/mperham/sidekiq/wiki/Testing)). Thus, only include ```gem "rspec-sidekiq"``` in environments where this behaviour is required, such as the ```test``` group.*
31
-
32
- If you are using Sidekiq Batches ([Sidekiq Pro feature](https://github.com/mperham/sidekiq/wiki/Batches)), ```rspec-sidekiq``` replaces the implementation (using the NullObject pattern) enabling testing without a Redis instance. Mocha and RSpec stubbing is supported here.
33
-
34
- ## Configuration
35
- If you wish to modify the default behaviour, add the following to your ```spec_helper.rb``` file
36
- ```ruby
37
- RSpec::Sidekiq.configure do |config|
38
- # Clears all job queues before each example
39
- config.clear_all_enqueued_jobs = false # default => true
40
- end
41
- ```
42
-
43
- ## Matchers
44
- * [be_processed_in](#be_processed_in)
45
- * [be_retryable](#be_retryable)
46
- * [be_unique](#be_unique)
47
- * [have_enqueued_job](#have_enqueued_job)
48
- * [have_enqueued_jobs](#have_enqueued_jobs)
49
-
50
- ### be_processed_in
51
- *Describes the queue that the job should be processed in*
52
- ```ruby
53
- sidekiq_options queue: :download # job option
54
-
55
- it { should be_processed_in :download } # one liner
56
- expect(AwesomeJob).to be_processed_in :download # new expect syntax
57
- ```
58
-
59
- ### be_retryable
60
- *Describes if the job retries when there is a failure in it's execution*
61
- ```ruby
62
- sidekiq_options retry: 5 # job option
63
-
64
- it { should be_retryable true } # one liner
65
- expect(AwesomeJob).to be_retryable true # new expect syntax
66
- # ...or alternatively specifiy the number of times it should be retried
67
- it { should be_retryable 5 } # one liner
68
- expect(AwesomeJob).to be_retryable 5 # new expect syntax
69
- ```
70
-
71
- ### be_unique
72
- *Describes if the job should be unique within it's queue*
73
- ```ruby
74
- sidekiq_options unique: true # job option
75
-
76
- it { should be_unique } # one liner
77
- expect(AwesomeJob).to be_unique # new expect syntax
78
- ```
79
-
80
- ### have_enqueued_job
81
- *Evaluates that there is an enqueued job with the specified arguments*
82
- ```ruby
83
- expect(AwesomeJob).to have_enqueued_job("Awesome", true) # new expect syntax
84
- ```
85
-
86
- ### have_enqueued_jobs
87
- *Evaluates the number of enqueued jobs for a specified job class*
88
- ```ruby
89
- expect(AwesomeJob).to have_enqueued_jobs(1) # new expect syntax
90
- # ...but you could just use
91
- expect(AwesomeJob).to have(1).jobs
92
- # ...or even
93
- expect(AwesomeJob).to have(1).enqueued.jobs
94
- ```
95
-
96
- ## Example
97
- ```ruby
98
- require "spec_helper"
99
-
100
- describe AwesomeJob do
101
- it { should be_processed_in :download }
102
- it { should be_retryable false }
103
- it { should be_unique }
104
-
105
- it "enqueues another awesome job" do
106
- subject.perform
107
-
108
- expect(AnotherAwesomeJob).to have_enqueued_job("Awesome", true)
109
- end
110
- end
111
- ```
112
-
113
- ## Testing
114
- ```bundle exec rspec spec```
115
-
116
- ## Contribute
117
- Please do! If there's a feature missing that you'd love to see then get in on the action!
118
-
119
- Issues/Pull Requests/Comments bring them on...
120
-
121
- [code_climate]: https://codeclimate.com/github/philostler/rspec-sidekiq
122
- [code_climate_badge]: https://codeclimate.com/github/philostler/rspec-sidekiq.png
123
- [coderwall]: https://coderwall.com/philostler
124
- [coderwall_badge]: https://api.coderwall.com/philostler/endorsecount.png
125
- [coveralls]: https://coveralls.io/r/philostler/rspec-sidekiq
126
- [coveralls_badge]: https://coveralls.io/repos/philostler/rspec-sidekiq/badge.png?branch=master
127
- [gem_version_badge]: https://badge.fury.io/rb/rspec-sidekiq.png
128
- [gemnasium]: https://gemnasium.com/philostler/rspec-sidekiq
129
- [gemnasium_badge]: https://gemnasium.com/philostler/rspec-sidekiq.png
130
- [github]: http://github.com/philostler/rspec-sidekiq
131
- [ruby_doc]: http://rubydoc.info/github/philostler/rspec-sidekiq/master/frames
132
- [ruby_gems]: http://rubygems.org/gems/rspec-sidekiq
133
- [ruby_toolbox]: http://www.ruby-toolbox.com/projects/rspec-sidekiq
134
- [travis_ci]: http://travis-ci.org/philostler/rspec-sidekiq
135
- [travis_ci_badge]: https://secure.travis-ci.org/philostler/rspec-sidekiq.png
1
+ # RSpec for Sidekiq
2
+
3
+ [![RubyGems][gem_version_badge]][ruby_gems]
4
+ [![Code Climate][code_climate_badge]][code_climate]
5
+ [![Travis CI][travis_ci_badge]][travis_ci]
6
+ [![Coveralls][coveralls_badge]][coveralls]
7
+ [![Gemnasium][gemnasium_badge]][gemnasium]
8
+ [![coderwall][coderwall_badge]][coderwall]
9
+
10
+ *Simple testing of Sidekiq jobs via a collection of matchers and helpers*
11
+
12
+ [RubyGems][ruby_gems] |
13
+ [Code Climate][code_climate] |
14
+ [GitHub][github] |
15
+ [Travis CI][travis_ci] |
16
+ [Coveralls][coveralls] |
17
+ [Gemnasium][gemnasium] |
18
+ [RubyDoc][ruby_doc] |
19
+ [Ruby Toolbox][ruby_toolbox]
20
+
21
+ [Jump to Matchers »](#matchers) | [Jump to Helpers »](#helpers)
22
+
23
+ ## Installation
24
+ ```ruby
25
+ # Gemfile
26
+ group :test do
27
+ gem "rspec-sidekiq"
28
+ end
29
+ ```
30
+ rspec-sidekiq requires ```sidekiq/testing``` by default so there is no need to include the line ```require "sidekiq/testing"``` inside your ```spec_helper.rb```.
31
+
32
+ *IMPORTANT! This has the effect of not pushing enqueued jobs to Redis but to a ```job``` array to enable testing ([see the FAQ & Troubleshooting Wiki page][rspec_sidekiq_wiki_faq_&_troubleshooting]). Thus, only include ```gem "rspec-sidekiq"``` in environments where this behaviour is required, such as the ```test``` group.*
33
+
34
+ ## Configuration
35
+ If you wish to modify the default behaviour, add the following to your ```spec_helper.rb``` file
36
+ ```ruby
37
+ RSpec::Sidekiq.configure do |config|
38
+ # Clears all job queues before each example
39
+ config.clear_all_enqueued_jobs = true # default => true
40
+
41
+ # Whether to use terminal colours when outputting messages
42
+ config.enable_terminal_colours = true # default => true
43
+
44
+ # Warn when jobs are not enqueued to Redis but to a job array
45
+ config.warn_when_jobs_not_processed_by_sidekiq = true # default => true
46
+ end
47
+ ```
48
+
49
+ ## Matchers
50
+ * [be_delayed](#be_delayed)
51
+ * [be_processed_in](#be_processed_in)
52
+ * [be_retryable](#be_retryable)
53
+ * [be_unique](#be_unique)
54
+ * [have_enqueued_job](#have_enqueued_job)
55
+ * ~~[have_enqueued_jobs](#have_enqueued_jobs)~~
56
+
57
+ ### be_delayed
58
+ *Describes a method that should be invoked asynchronously (See [Sidekiq Delayed Extensions][sidekiq_wiki_delayed_extensions])*
59
+ ```ruby
60
+ Object.delay.is_nil? # delay
61
+ expect(Object.method :is_nil?).to be_delayed
62
+ Object.delay.is_a? Object # delay with argument
63
+ expect(Object.method :is_a?).to be_delayed(Object)
64
+
65
+ Object.delay_for(1.hour).is_nil? # delay for
66
+ expect(Object.method :is_nil?).to be_delayed.for 1.hour
67
+ Object.delay_for(1.hour).is_a? Object # delay for with argument
68
+ expect(Object.method :is_a?).to be_delayed(Object).for 1.hour
69
+
70
+ Object.delay_until(1.hour.from_now).is_nil? # delay until
71
+ expect(Object.method :is_nil?).to be_delayed.until 1.hour.from_now
72
+ Object.delay_until(1.hour.from_now).is_a? Object # delay until with argument
73
+ expect(Object.method :is_a?).to be_delayed(Object).until 1.hour.from_now
74
+ ```
75
+
76
+ ### be_processed_in
77
+ *Describes the queue that a job should be processed in*
78
+ ```ruby
79
+ sidekiq_options queue: :download
80
+ # test with...
81
+ expect(AwesomeJob).to be_processed_in :download # or
82
+ it { should be_processed_in :download }
83
+ ```
84
+
85
+ ### be_retryable
86
+ *Describes if a job should retry when there is a failure in it's execution*
87
+ ```ruby
88
+ sidekiq_options retry: 5
89
+ # test with...
90
+ expect(AwesomeJob).to be_retryable true # or
91
+ it { should be_retryable true }
92
+ # ...or alternatively specifiy the number of times it should be retried
93
+ expect(AwesomeJob).to be_retryable 5 # or
94
+ it { should be_retryable 5 }
95
+ # ...or when it should not retry
96
+ expect(AwesomeJob).to be_retryable false # or
97
+ it { should be_retryable false }
98
+ ```
99
+
100
+ ### be_unique
101
+ *Describes when a job should be unique within it's queue*
102
+ ```ruby
103
+ sidekiq_options unique: true
104
+ # test with...
105
+ expect(AwesomeJob).to be_unique
106
+ it { should be_unique }
107
+ ```
108
+
109
+ ### have_enqueued_job
110
+ *Describes that there should be an enqueued job with the specified arguments*
111
+ ```ruby
112
+ Awesomejob.perform_async "Awesome", true
113
+ # test with...
114
+ expect(AwesomeJob).to have_enqueued_job("Awesome", true)
115
+ ```
116
+
117
+ ### ~~have_enqueued_jobs~~
118
+ *Removed. [See the FAQ & Troubleshooting Wiki page][rspec_sidekiq_wiki_faq_&_troubleshooting] for alternative and more information*
119
+
120
+ ## Example matcher usage
121
+ ```ruby
122
+ require "spec_helper"
123
+
124
+ describe AwesomeJob do
125
+ it { should be_processed_in :my_queue }
126
+ it { should be_retryable 5 }
127
+ it { should be_unique }
128
+
129
+ it "enqueues another awesome job" do
130
+ subject.perform
131
+
132
+ expect(AnotherAwesomeJob).to have_enqueued_job("Awesome", true)
133
+ end
134
+ end
135
+ ```
136
+
137
+ ## Helpers
138
+ * [Batches](#batches)
139
+ * [within_sidekiq_retries_exhausted_block](#within_sidekiq_retries_exhausted_block)
140
+
141
+ ### Batches
142
+ If you are using Sidekiq Batches ([Sidekiq Pro feature][sidekiq_wiki_batches]), rspec-sidekiq replaces the implementation (using the NullObject pattern) enabling testing without a Redis instance. Mocha and RSpec stubbing is supported here.
143
+
144
+ ### within_sidekiq_retries_exhausted_block
145
+ ```ruby
146
+ sidekiq_retries_exhausted do |msg|
147
+ bar('hello')
148
+ end
149
+ # test with...
150
+ FooClass.within_sidekiq_retries_exhausted_block {
151
+ expect(FooClass).to receive(:bar).with("hello")
152
+ }
153
+ ```
154
+
155
+ ## Testing
156
+ ```bundle exec rspec spec```
157
+
158
+ ## Contribute
159
+ Please do! If there's a feature missing that you'd love to see then get in on the action!
160
+
161
+ Issues/Pull Requests/Comments all welcome...
162
+
163
+ [code_climate]: https://codeclimate.com/github/philostler/rspec-sidekiq
164
+ [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
+ [coveralls]: https://coveralls.io/r/philostler/rspec-sidekiq
168
+ [coveralls_badge]: https://coveralls.io/repos/philostler/rspec-sidekiq/badge.png?branch=master
169
+ [gem_version_badge]: https://badge.fury.io/rb/rspec-sidekiq.png
170
+ [gemnasium]: https://gemnasium.com/philostler/rspec-sidekiq
171
+ [gemnasium_badge]: https://gemnasium.com/philostler/rspec-sidekiq.png
172
+ [github]: http://github.com/philostler/rspec-sidekiq
173
+ [ruby_doc]: http://rubydoc.info/github/philostler/rspec-sidekiq/master/frames
174
+ [ruby_gems]: http://rubygems.org/gems/rspec-sidekiq
175
+ [ruby_toolbox]: http://www.ruby-toolbox.com/projects/rspec-sidekiq
176
+ [travis_ci]: http://travis-ci.org/philostler/rspec-sidekiq
177
+ [travis_ci_badge]: https://secure.travis-ci.org/philostler/rspec-sidekiq.png
178
+
179
+ [rspec_sidekiq_wiki_faq_&_troubleshooting]: https://github.com/philostler/rspec-sidekiq/wiki/FAQ-&-Troubleshooting
180
+ [sidekiq_wiki_batches]: https://github.com/mperham/sidekiq/wiki/Batches
181
+ [sidekiq_wiki_delayed_extensions]: https://github.com/mperham/sidekiq/wiki/Delayed-Extensions