rspec-sidekiq 0.3.0 → 0.4.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODc2ZWI3NTdmZjk2MTY3N2I4YmMyNzYxOTQ2MjE4NTY2NWE1OGQ4Yw==
4
+ MzgyMTA1YzA0ZTU2MjU3YjJhNGQ0NzI0YmVkMjJkYTdmYTc3MzUzMg==
5
5
  data.tar.gz: !binary |-
6
- Zjk0MjBkYTY4NTNiZjlkNWZlZTRhZGVkNzRhYWM3YjcyMWQyYmRjZg==
6
+ YzE0MzllMDU3MmQyZjI0MGM0YzA4ZTFhZjkxMjVkN2QxODNmNjdhZg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NmNmNDZiYzFkZGU4OWRjNWQ0MjdiZDIwOTY5YzA1YzY4OWI5ZDlkZTQ3NGM3
10
- ZmM3NGQ0MzE3NjNhMmQ2ZTE0NzY0NWVhMWQyOTc0OWQ3YTVkODE1N2RmMTIz
11
- ZWQyMmYyY2Q5OTAyOGM3NDEwNDhmYjRhMDA2MWVmNGMwNGNlNjA=
9
+ NWIzZGE3MmZjM2I1MmQzN2M5NTdiOGY0ZmZhMjc0Nzg2NmQ1OTk4ZDE3M2I0
10
+ OTMyMjk2ZWMzODkxMDQ5OTIyZWEyYTM5NGVlYWEwMjU2MDhjOGI1NTBmMzFl
11
+ Yjc2ODY0YjQ0MDNkMWY1ZGY4OThkZWNmYmQwZGE1NjFhN2I4NWM=
12
12
  data.tar.gz: !binary |-
13
- YTYxZDBhYmJlOTg5MTA4YjVkZGU0ZTM4NjE4OTg4MzlmN2ZmYzBjNzZjZDk4
14
- OTM1NGI3YmE1MmQ3YWViZTdkMWRhOTFjOGNjZjA0ZjQ1NmUxN2QyYmJiZWVl
15
- MGY2NjNhMmE1NTUwNjk5Nzk1YmQwMjc4NTU3NDUwZWZkMzQ4MDk=
13
+ ZjdjYzcyMGE1OTE2NTU4MmMzNWUyNGMyYjU2NzBkNWUxNTUxMDgwZjMyMDM2
14
+ N2MyNjVhNjVlZDQ0ZmY4Yzg3MzY2ZjVlMWQ0NWM1Yzg0OTk0OWFiZjRmMzk5
15
+ OTc1ZGRlM2RiZmFlNmNjMTY5MDIyZDFjMzJhZmY1OTNjMTdlMDU=
data/.gitignore CHANGED
@@ -1,163 +1,2 @@
1
- #################
2
- ## Eclipse
3
- #################
4
-
5
- *.pydevproject
6
- .project
7
- .metadata
8
- bin/
9
- tmp/
10
- *.tmp
11
- *.bak
12
- *.swp
13
- *~.nib
14
- local.properties
15
- .classpath
16
- .settings/
17
- .loadpath
18
-
19
- # External tool builders
20
- .externalToolBuilders/
21
-
22
- # Locally stored "Eclipse launch configurations"
23
- *.launch
24
-
25
- # CDT-specific
26
- .cproject
27
-
28
- # PDT-specific
29
- .buildpath
30
-
31
-
32
- #################
33
- ## Visual Studio
34
- #################
35
-
36
- ## Ignore Visual Studio temporary files, build results, and
37
- ## files generated by popular Visual Studio add-ons.
38
-
39
- # User-specific files
40
- *.suo
41
- *.user
42
- *.sln.docstates
43
-
44
- # Build results
45
- [Dd]ebug/
46
- [Rr]elease/
47
- *_i.c
48
- *_p.c
49
- *.ilk
50
- *.meta
51
- *.obj
52
- *.pch
53
- *.pdb
54
- *.pgc
55
- *.pgd
56
- *.rsp
57
- *.sbr
58
- *.tlb
59
- *.tli
60
- *.tlh
61
- *.tmp
62
- *.vspscc
63
- .builds
64
- *.dotCover
65
-
66
- ## TODO: If you have NuGet Package Restore enabled, uncomment this
67
- #packages/
68
-
69
- # Visual C++ cache files
70
- ipch/
71
- *.aps
72
- *.ncb
73
- *.opensdf
74
- *.sdf
75
-
76
- # Visual Studio profiler
77
- *.psess
78
- *.vsp
79
-
80
- # ReSharper is a .NET coding add-in
81
- _ReSharper*
82
-
83
- # Installshield output folder
84
- [Ee]xpress
85
-
86
- # DocProject is a documentation generator add-in
87
- DocProject/buildhelp/
88
- DocProject/Help/*.HxT
89
- DocProject/Help/*.HxC
90
- DocProject/Help/*.hhc
91
- DocProject/Help/*.hhk
92
- DocProject/Help/*.hhp
93
- DocProject/Help/Html2
94
- DocProject/Help/html
95
-
96
- # Click-Once directory
97
- publish
98
-
99
- # Others
100
- [Bb]in
101
- [Oo]bj
102
- sql
103
- TestResults
104
- *.Cache
105
- ClientBin
106
- stylecop.*
107
- ~$*
108
- *.dbmdl
109
- Generated_Code #added for RIA/Silverlight projects
110
-
111
- # Backup & report files from converting an old project file to a newer
112
- # Visual Studio version. Backup files are not needed, because we have git ;-)
113
- _UpgradeReport_Files/
114
- Backup*/
115
- UpgradeLog*.XML
116
-
117
-
118
-
119
- ############
120
- ## Windows
121
- ############
122
-
123
- # Windows image file caches
124
- Thumbs.db
125
-
126
- # Folder config file
127
- Desktop.ini
128
-
129
-
130
- #############
131
- ## Python
132
- #############
133
-
134
- *.py[co]
135
-
136
- # Packages
137
- *.egg
138
- *.egg-info
139
- dist
140
- build
141
- eggs
142
- parts
143
- bin
144
- var
145
- sdist
146
- develop-eggs
147
- .installed.cfg
148
-
149
- # Installer logs
150
- pip-log.txt
151
-
152
- # Unit test / coverage reports
153
- .coverage
154
- .tox
155
-
156
- #Translations
157
- *.mo
158
-
159
- #Mr Developer
160
- .mr.developer.cfg
161
-
162
- # Mac crap
163
- .DS_Store
1
+ Gemfile.lock
2
+ spec_result
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
1
  --colour
2
2
  --format Fuubar
3
- --format html --out rspec_results.html
3
+ --format html --out spec_result/rspec.html
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ 0.4.0
2
+ ---
3
+ * Bug fix for matcher failure if sidekiq_options were defined as strings vs symbols [mhuffnagle#16 & philostler]
4
+ * Matcher tests (partial coverage) added [mhuffnagle#16 & philostler]
5
+
1
6
  0.3.0
2
7
  ---
3
8
  * Removed restriction on needing to use sidekiq-middleware with be_unique matcher [philostler#4]
data/README.md CHANGED
@@ -1,13 +1,32 @@
1
- # RSpec for Sidekiq [![RubyGems][gem_version_badge]][ruby_gems] [![Code Climate][code_climate_badge]][code_climate] [![Travis CI][travis_ci_badge]][travis_ci] [![Gemnasium][gemnasium_badge]][gemnasium]
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
+
2
9
  *Simple testing of Sidekiq jobs via a collection of matchers and common tasks*
3
10
 
4
- [RubyGems][ruby_gems] | [Code Climate][code_climate] | [GitHub][github] | [Travis CI][travis_ci] | [Gemnasium][gemnasium] | [RubyDoc][ruby_doc] | [Ruby Toolbox][ruby_toolbox]
11
+ [RubyGems][ruby_gems] |
12
+ [Code Climate][code_climate] |
13
+ [GitHub][github] |
14
+ [Travis CI][travis_ci] |
15
+ [Coveralls][coveralls] |
16
+ [Gemnasium][gemnasium] |
17
+ [RubyDoc][ruby_doc] |
18
+ [Ruby Toolbox][ruby_toolbox]
5
19
 
6
20
  ## Installation
21
+ ```ruby
22
+ # Gemfile
23
+ group :test do
24
+ gem "rspec-sidekiq"
25
+ end
7
26
  ```
8
- gem "rspec-sidekiq"
9
- ```
10
- There is no need to ```require "sidekiq/testing"``` when using rspec-sidekiq
27
+ ```rspec-sidekiq``` requires ```sidekiq/testing``` by default so there is no need to include the line ```require "sidekiq/testing"``` inside your ```spec_helper.rb```.
28
+
29
+ *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*
11
30
 
12
31
  ## Configuration
13
32
  If you wish to modify the default behaviour, add the following to your ```spec_helper.rb``` file
@@ -28,17 +47,21 @@ end
28
47
  ### be_processed_in
29
48
  *Describes the queue that the job should be processed in*
30
49
  ```ruby
31
- it { should be_processed_in :download } } # one liner
50
+ sidekiq_options queue: :download # job option
51
+
52
+ it { should be_processed_in :download } # one liner
32
53
  expect(AwesomeJob).to be_processed_in :download # new expect syntax
33
54
  ```
34
55
 
35
56
  ### be_retryable
36
57
  *Describes if the job retries when there is a failure in it's execution*
37
58
  ```ruby
38
- it { should be_retryable true } } # one liner
59
+ sidekiq_options retry: 5 # job option
60
+
61
+ it { should be_retryable true } # one liner
39
62
  expect(AwesomeJob).to be_retryable true # new expect syntax
40
63
  # ...or alternatively specifiy the number of times it should be retried
41
- it { should be_retryable 5 } } # one liner
64
+ it { should be_retryable 5 } # one liner
42
65
  expect(AwesomeJob).to be_retryable 5 # new expect syntax
43
66
  ```
44
67
 
@@ -47,7 +70,7 @@ expect(AwesomeJob).to be_retryable 5 # new expect syntax
47
70
  ```ruby
48
71
  sidekiq_options unique: true # job option
49
72
 
50
- it { should be_unique } } # one liner
73
+ it { should be_unique } # one liner
51
74
  expect(AwesomeJob).to be_unique # new expect syntax
52
75
  ```
53
76
 
@@ -94,6 +117,8 @@ Issues/Pull Requests/Comments bring them on...
94
117
 
95
118
  [code_climate]: https://codeclimate.com/github/philostler/rspec-sidekiq
96
119
  [code_climate_badge]: https://codeclimate.com/github/philostler/rspec-sidekiq.png
120
+ [coveralls]: https://coveralls.io/r/philostler/rspec-sidekiq
121
+ [coveralls_badge]: https://coveralls.io/repos/philostler/rspec-sidekiq/badge.png?branch=master
97
122
  [gem_version_badge]: https://badge.fury.io/rb/rspec-sidekiq.png
98
123
  [gemnasium]: https://gemnasium.com/philostler/rspec-sidekiq
99
124
  [gemnasium_badge]: https://gemnasium.com/philostler/rspec-sidekiq.png
@@ -19,9 +19,9 @@ module RSpec
19
19
  end
20
20
 
21
21
  def matches? job
22
- @klass = job.class
22
+ @klass = job.kind_of?(Class) ? job : job.class
23
23
  @actual = @klass.get_sidekiq_options["queue"]
24
- @actual == @expected
24
+ @actual.to_s == @expected.to_s
25
25
  end
26
26
 
27
27
  def negative_failure_message
@@ -25,7 +25,7 @@ module RSpec
25
25
  end
26
26
 
27
27
  def matches? job
28
- @klass = job.class
28
+ @klass = job.kind_of?(Class) ? job : job.class
29
29
  @actual = @klass.get_sidekiq_options["retry"]
30
30
  @actual == @expected
31
31
  end
@@ -15,7 +15,7 @@ module RSpec
15
15
  end
16
16
 
17
17
  def matches? job
18
- @klass = job.class
18
+ @klass = job.kind_of?(Class) ? job : job.class
19
19
  @actual = @klass.get_sidekiq_options["unique"]
20
20
  @actual == true
21
21
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Sidekiq
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.add_dependency "rspec", "~> 2.0"
16
16
  s.add_dependency "sidekiq", ">= 2.4.0"
17
17
 
18
+ s.add_development_dependency "coveralls", "~> 0.6.0"
18
19
  s.add_development_dependency "fuubar", "~> 1.1"
19
20
  s.add_development_dependency "rspec", "~> 2.0"
20
21
  s.add_development_dependency "sidekiq", ">= 2.4.0"
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ describe "Be Processed In matcher" do
4
+ subject { TestWorker }
5
+
6
+ describe "expect syntax" do
7
+ context "when queue is specified as a string" do
8
+ it "correctly matches" do
9
+ expect(TestWorker).to be_processed_in "data"
10
+ end
11
+ end
12
+
13
+ context "when queue is specified as a symbol" do
14
+ it "correctly matches" do
15
+ expect(TestWorker).to be_processed_in :data
16
+ end
17
+ end
18
+ end
19
+
20
+ describe "one liner syntax" do
21
+ context "when queue is specified as a string" do
22
+ expect_it { to be_processed_in "data" }
23
+ end
24
+
25
+ context "when queue is specified as a symbol" do
26
+ expect_it { to be_processed_in :data }
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,41 @@
1
+ require "spec_helper"
2
+
3
+ describe "Be Retryable matcher" do
4
+
5
+ describe "expect syntax" do
6
+ context "when retryable is number" do
7
+ it "correctly matches" do
8
+ expect(TestWorker).to be_retryable 5
9
+ end
10
+ end
11
+
12
+ context "when retryable is true" do
13
+ it "correctly matches" do
14
+ expect(TestWorkerDefaults).to be_retryable true
15
+ end
16
+ end
17
+
18
+ context "when retryable is false" do
19
+ it "correctly matches" do
20
+ expect(TestWorkerAlternative).to be_retryable false
21
+ end
22
+ end
23
+ end
24
+
25
+ describe "one liner syntax" do
26
+ context "when retryable is number" do
27
+ subject { TestWorker }
28
+ expect_it { to be_retryable 5 }
29
+ end
30
+
31
+ context "when retryable is true" do
32
+ subject { TestWorkerDefaults }
33
+ expect_it { to be_retryable true }
34
+ end
35
+
36
+ context "when retryable is false" do
37
+ subject { TestWorkerAlternative }
38
+ expect_it { to be_retryable false }
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+
3
+ describe "Be Unique matcher" do
4
+ subject { TestWorker }
5
+
6
+ describe "expect syntax" do
7
+ it "correctly matches" do
8
+ expect(TestWorker).to be_unique
9
+ end
10
+ end
11
+
12
+ describe "one liner syntax" do
13
+ expect_it { to be_unique }
14
+ end
15
+ end
@@ -3,5 +3,5 @@ require "spec_helper"
3
3
  describe "Version" do
4
4
  subject { RSpec::Sidekiq::VERSION }
5
5
 
6
- expect_it { to eq("0.3.0") }
6
+ expect_it { to eq("0.4.0") }
7
7
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,17 @@
1
+ require "simplecov"
2
+ require "coveralls"
3
+
1
4
  require "sidekiq"
2
5
  require "rspec-sidekiq"
3
6
 
7
+ require_relative "support/init"
8
+
9
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
10
+ Coveralls::SimpleCov::Formatter,
11
+ SimpleCov::Formatter::HTMLFormatter
12
+ ]
13
+ SimpleCov.start
14
+
4
15
  RSpec.configure do |config|
5
16
  config.alias_example_to :expect_it
6
17
 
@@ -0,0 +1,3 @@
1
+ require_relative "test_worker"
2
+ require_relative "test_worker_alternative"
3
+ require_relative "test_worker_defaults"
@@ -0,0 +1,8 @@
1
+ class TestWorker
2
+ include Sidekiq::Worker
3
+
4
+ sidekiq_options queue: :data, retry: 5, unique: true
5
+
6
+ def perform
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ class TestWorkerAlternative
2
+ include Sidekiq::Worker
3
+
4
+ sidekiq_options queue: "data", retry: false, unique: false
5
+
6
+ def perform
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ class TestWorkerDefaults
2
+ include Sidekiq::Worker
3
+
4
+ def perform
5
+ end
6
+ 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: 0.3.0
4
+ version: 0.4.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: 2013-04-09 00:00:00.000000000 Z
11
+ date: 2013-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.4.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.6.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.6.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: fuubar
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -105,8 +119,15 @@ files:
105
119
  - lib/rspec/sidekiq/sidekiq.rb
106
120
  - lib/rspec/sidekiq/version.rb
107
121
  - lib/rspec-sidekiq.rb
122
+ - spec/rspec/sidekiq/matchers/be_processed_in_spec.rb
123
+ - spec/rspec/sidekiq/matchers/be_retryable_spec.rb
124
+ - spec/rspec/sidekiq/matchers/be_unique_spec.rb
108
125
  - spec/rspec/sidekiq/version_spec.rb
109
126
  - spec/spec_helper.rb
127
+ - spec/support/init.rb
128
+ - spec/support/test_worker.rb
129
+ - spec/support/test_worker_alternative.rb
130
+ - spec/support/test_worker_defaults.rb
110
131
  homepage: http://github.com/philostler/rspec-sidekiq
111
132
  licenses:
112
133
  - MIT