rspec-sidekiq 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWIxZWYzZjY0YTY0OWMyZTJhM2UyMjMyM2Q4OTU4MmQxMmQzNWFjZg==
5
+ data.tar.gz: !binary |-
6
+ YjZiNDNiOGE5NGUxN2I1Mzg3ZDFiOTQ5OTMzNDY5NDk5OWIxNWIwOQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NmY0MTFhMjE2NWM5NTM2NDhjNWJmOWY2ZWQ0YzVhYTY1ZDdhOGViMmZkNTBj
10
+ Njk3MjZjZGM2ZjQ5NWFlY2Q2MjM0MTg2MTY3YThhMGI2M2EwYWE0YjQ3MjI0
11
+ MTkwZDE4NTk1NTgzMWU4ZTE5YmY4ZmVkMTQyYmIzYjlhMTQ2ODg=
12
+ data.tar.gz: !binary |-
13
+ ODg2ZTJlNjQ3MDE0NmI1NDZmNmEzZDI0NTc3ZDgzNzUzN2FmMDY1N2QxMjE4
14
+ YWRkN2VlY2IyMjNjYmMxZmJiYjNmODUyNjQyMGViYzUzOTI1YjAxNGYxYzU3
15
+ YTVkMzY4OTRmODg0YjJhZWVmZDllODlkMWFhOTEwMGExYzJkMGU=
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.2.0
2
+ ---
3
+ * New #have_enqueued_job matcher
4
+ # Improved #have_enqueued_jobs description
5
+ * Minor documentation updates
6
+
1
7
  0.1.0
2
8
  ---
3
9
  * Initial release
data/README.md CHANGED
@@ -21,6 +21,7 @@ end
21
21
  * [be_processed_in](#be_processed_in)
22
22
  * [be_retryable](#be_retryable)
23
23
  * [be_unique](#be_unique)
24
+ * [have_enqueued_job](#have_enqueued_job)
24
25
  * [have_enqueued_jobs](#have_enqueued_jobs)
25
26
 
26
27
  ### be_processed_in
@@ -35,6 +36,9 @@ expect(AwesomeJob).to be_processed_in :download # new expect syntax
35
36
  ```ruby
36
37
  it { should be_retryable true } } # one liner
37
38
  expect(AwesomeJob).to be_retryable true # new expect syntax
39
+ # ...or alternatively specifiy the number of times it should be retried
40
+ it { should be_retryable 5 } } # one liner
41
+ expect(AwesomeJob).to be_retryable 5 # new expect syntax
38
42
  ```
39
43
 
40
44
  ### be_unique (Only available when using [sidekiq-middleware](https://github.com/krasnoukhov/sidekiq-middleware))
@@ -44,10 +48,20 @@ it { should be_unique } } # one liner
44
48
  expect(AwesomeJob).to be_unique # new expect syntax
45
49
  ```
46
50
 
51
+ ### have_enqueued_job
52
+ *Evaluates that there is an enqueued job with the specified arguments*
53
+ ```ruby
54
+ expect(AwesomeJob).to have_enqueued_job("Awesome", true) # new expect syntax
55
+ ```
56
+
47
57
  ### have_enqueued_jobs
48
- *Evaluates the number of enqueued jobs for a specified job*
58
+ *Evaluates the number of enqueued jobs for a specified job class*
49
59
  ```ruby
50
60
  expect(AwesomeJob).to have_enqueued_jobs(1) # new expect syntax
61
+ # ...but you could just use
62
+ expect(AwesomeJob).to have(1).jobs
63
+ # ...or even
64
+ expect(AwesomeJob).to have(1).enqueued.jobs
51
65
  ```
52
66
 
53
67
  ## Testing
@@ -67,4 +81,4 @@ Issues/Pull Requests/Comments bring them on...
67
81
  [ruby_gems]: http://rubygems.org/gems/rspec-sidekiq
68
82
  [ruby_toolbox]: http://www.ruby-toolbox.com/projects/rspec-sidekiq
69
83
  [travis_ci]: http://travis-ci.org/philostler/rspec-sidekiq
70
- [travis_ci_badge]: https://secure.travis-ci.org/philostler/rspec-sidekiq.png
84
+ [travis_ci_badge]: https://secure.travis-ci.org/philostler/rspec-sidekiq.png
@@ -1,5 +1,6 @@
1
1
  require "rspec/sidekiq/matchers/be_processed_in"
2
2
  require "rspec/sidekiq/matchers/be_retryable"
3
+ require "rspec/sidekiq/matchers/have_enqueued_job"
3
4
  require "rspec/sidekiq/matchers/have_enqueued_jobs"
4
5
 
5
6
  if defined?(Sidekiq::Middleware::Client::UniqueJobs)
@@ -0,0 +1,35 @@
1
+ module RSpec
2
+ module Sidekiq
3
+ module Matchers
4
+ def have_enqueued_job *expected
5
+ HaveEnqueuedJob.new expected
6
+ end
7
+
8
+ class HaveEnqueuedJob
9
+ def initialize expected
10
+ @expected = expected
11
+ end
12
+
13
+ def description
14
+ "have an enqueued #{@klass} job with arguments #{@expected}"
15
+ end
16
+
17
+ def failure_message
18
+ "expected to have an enqueued #{@klass} job with arguments #{@expected} but none found\n\n" +
19
+ "found: #{@actual}"
20
+ end
21
+
22
+ def matches? klass
23
+ @klass = klass
24
+ @actual = klass.jobs.map { |job| job["args"] }
25
+ puts @actual
26
+ @actual.include? @expected
27
+ end
28
+
29
+ def negative_failure_message
30
+ "expected to not have an enqueued #{@klass} job with arguments #{@expected}"
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -11,11 +11,15 @@ module RSpec
11
11
  end
12
12
 
13
13
  def description
14
- "enqueues a #{@klass} job"
14
+ "have #{@expected} enqueued #{@klass} job#{jobs_description}"
15
15
  end
16
16
 
17
17
  def failure_message
18
- "expected #{@klass} to have #{@expected} enqueued jobs but got #{@actual}"
18
+ "expected #{@klass} to have #{@expected} enqueued job#{jobs_description} but got #{@actual}"
19
+ end
20
+
21
+ def jobs_description
22
+ "s" unless @expected == 1
19
23
  end
20
24
 
21
25
  def matches? klass
@@ -25,7 +29,7 @@ module RSpec
25
29
  end
26
30
 
27
31
  def negative_failure_message
28
- "expected #{@klass} to not have #{@expected} enqueued jobs"
32
+ "expected #{@klass} to not have #{@expected} enqueued job#{jobs_description}"
29
33
  end
30
34
  end
31
35
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module Sidekiq
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  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.1.0") }
6
+ expect_it { to eq("0.2.0") }
7
7
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-sidekiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Phil Ostler
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-24 00:00:00.000000000 Z
11
+ date: 2013-03-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: sidekiq
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: fuubar
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: sidekiq
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -110,6 +99,7 @@ files:
110
99
  - lib/rspec/sidekiq/matchers/be_processed_in.rb
111
100
  - lib/rspec/sidekiq/matchers/be_retryable.rb
112
101
  - lib/rspec/sidekiq/matchers/be_unique.rb
102
+ - lib/rspec/sidekiq/matchers/have_enqueued_job.rb
113
103
  - lib/rspec/sidekiq/matchers/have_enqueued_jobs.rb
114
104
  - lib/rspec/sidekiq/matchers.rb
115
105
  - lib/rspec/sidekiq/sidekiq.rb
@@ -120,26 +110,25 @@ files:
120
110
  homepage: http://github.com/philostler/rspec-sidekiq
121
111
  licenses:
122
112
  - MIT
113
+ metadata: {}
123
114
  post_install_message:
124
115
  rdoc_options: []
125
116
  require_paths:
126
117
  - lib
127
118
  required_ruby_version: !ruby/object:Gem::Requirement
128
- none: false
129
119
  requirements:
130
120
  - - ! '>='
131
121
  - !ruby/object:Gem::Version
132
122
  version: '0'
133
123
  required_rubygems_version: !ruby/object:Gem::Requirement
134
- none: false
135
124
  requirements:
136
125
  - - ! '>='
137
126
  - !ruby/object:Gem::Version
138
127
  version: '0'
139
128
  requirements: []
140
129
  rubyforge_project:
141
- rubygems_version: 1.8.24
130
+ rubygems_version: 2.0.3
142
131
  signing_key:
143
- specification_version: 3
132
+ specification_version: 4
144
133
  summary: RSpec for Sidekiq
145
134
  test_files: []