rspec-sidekiq_pro 1.1.0 → 1.2.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
2
  SHA256:
3
- metadata.gz: 2cd253da9eb5bb4e1bbb68a9bf9c2453f200e2743120b1730f82bc9c51c346ab
4
- data.tar.gz: 63e909c970b1f4d29d1334f14b721a9c12478ca02cfef5d829d5046cea1ba733
3
+ metadata.gz: a19307da8e27eaf43f2ec679fde1ce55961ad0f61c48b01d13b086b408af6a71
4
+ data.tar.gz: 50db6bdf022a1fa024e527e7a0fa65bcbf52566a6b28e603ecf5626f4ecfa94d
5
5
  SHA512:
6
- metadata.gz: ec44fdba876447f815815d3f9bf510876aca1be41fe0324102fff0828285d3a9b214825c9c79966b342e42e4d109c2487052d33aa1cd99c0fff69c34253a5dc0
7
- data.tar.gz: c2692d557e4d997d3c17b895b7db57ca841b729bb643bbd2e1b8dfe3af410a80f959aee8db786e81d3787d282ec2f5a04a3f9dc5ac401bacf29fee08b3352d6a
6
+ metadata.gz: c36f3fa7655fef1b047eb84b8148cd40a7eee3bf131d8966469f03bae2ce214e065d21c36088e00c170717eb737bf0265206d8ddaea4a0ca1cde307bf91c7aa2
7
+ data.tar.gz: cc0fc1156ebb0b69aa95e82c7e83f9b3079a6b80fe7a7b920f026a7300c66661f9aaee440a566de5ca91a9e7b1463bc3b2e42482fc01b73a1efa013c347f8e9e
data/README.md CHANGED
@@ -55,7 +55,11 @@ Both matchers provide the same chainable methods:
55
55
  * `.with`
56
56
  * `.once`
57
57
  * `.twice`
58
- * `.exactly().times`
58
+ * `.exactly(n).times`
59
+ * `.more_than(n).times`
60
+ * `.less_than(n).times`
61
+ * `.at_least(n).times`
62
+ * `.at_most(n).times`
59
63
  * `.in`
60
64
  * `.at`
61
65
  * `.within_batch`
@@ -103,6 +107,14 @@ it do
103
107
  end
104
108
  ```
105
109
 
110
+ ```ruby
111
+ it do
112
+ expect {
113
+ 10.times { SampleJob.perform_async }
114
+ }.to enqueue_sidekiq_job(SampleJob).more_than(5).times
115
+ end
116
+ ```
117
+
106
118
  Be careful when checking both counts and arguments:
107
119
 
108
120
  ```ruby
@@ -89,7 +89,7 @@ module Sidekiq
89
89
  @bid = bid || SecureRandom.urlsafe_base64(10)
90
90
  props = RSpec::SidekiqPro::Batches::Props.fetch(bid, {})
91
91
 
92
- @created_at = props.fetch("created_at", Time.now.utc).to_f
92
+ @created_f = @created_at = props.fetch("created_at", Time.now.utc).to_f
93
93
  @description = props["description"]
94
94
  @parent_bid = props["parent"]
95
95
  @callbacks = props.fetch("callbacks", {})
@@ -12,6 +12,10 @@ module RSpec
12
12
  :expected_timestamp,
13
13
  :expected_schedule,
14
14
  :expected_count,
15
+ :expected_least_count,
16
+ :expected_most_count,
17
+ :expected_more_count,
18
+ :expected_less_count,
15
19
  :expected_without_batch,
16
20
  :expected_batch,
17
21
  :actual_jobs
@@ -52,8 +56,28 @@ module RSpec
52
56
  exactly(2)
53
57
  end
54
58
 
55
- def exactly(times)
56
- @expected_count = times
59
+ def exactly(count)
60
+ @expected_count = count
61
+ self
62
+ end
63
+
64
+ def at_least(count)
65
+ @expected_least_count = count
66
+ self
67
+ end
68
+
69
+ def at_most(count)
70
+ @expected_most_count = count
71
+ self
72
+ end
73
+
74
+ def more_than(count)
75
+ @expected_more_count = count
76
+ self
77
+ end
78
+
79
+ def less_than(count)
80
+ @expected_less_count = count
57
81
  self
58
82
  end
59
83
 
@@ -89,6 +113,14 @@ module RSpec
89
113
 
90
114
  if expected_count
91
115
  filtered_jobs.count == expected_count
116
+ elsif expected_least_count
117
+ filtered_jobs.count >= expected_least_count
118
+ elsif expected_most_count
119
+ filtered_jobs.count <= expected_most_count
120
+ elsif expected_more_count
121
+ filtered_jobs.count > expected_more_count
122
+ elsif expected_less_count
123
+ filtered_jobs.count < expected_less_count
92
124
  else
93
125
  filtered_jobs.any?
94
126
  end
@@ -100,6 +132,14 @@ module RSpec
100
132
 
101
133
  if expected_count
102
134
  filtered_jobs.count != expected_count
135
+ elsif expected_least_count
136
+ raise ArgumentError, "ambiguous `at_least` matcher used with negative form"
137
+ elsif expected_most_count
138
+ raise ArgumentError, "ambiguous `at_most` matcher used with negative form"
139
+ elsif expected_more_count
140
+ filtered_jobs.count < expected_more_count
141
+ elsif expected_less_count
142
+ filtered_jobs.count > expected_less_count
103
143
  else
104
144
  filtered_jobs.empty?
105
145
  end
@@ -122,6 +162,14 @@ module RSpec
122
162
  description += " twice"
123
163
  elsif expected_count
124
164
  description += " #{expected_count} times"
165
+ elsif expected_least_count
166
+ description += " at least #{expected_least_count} times"
167
+ elsif expected_most_count
168
+ description += " at most #{expected_most_count} times"
169
+ elsif expected_more_count
170
+ description += " more than #{expected_more_count} times"
171
+ elsif expected_less_count
172
+ description += " less than #{expected_less_count} times"
125
173
  end
126
174
 
127
175
  if expected_arguments.is_a?(Proc)
@@ -160,6 +208,10 @@ module RSpec
160
208
  def expectations_in_failure_message
161
209
  message = []
162
210
  message << " exactly: #{expected_count} time(s)" if expected_count
211
+ message << " at least: #{expected_least_count} time(s)" if expected_least_count
212
+ message << " at most: #{expected_most_count} time(s)" if expected_most_count
213
+ message << " more than: #{expected_more_count} time(s)" if expected_more_count
214
+ message << " less than: #{expected_less_count} time(s)" if expected_less_count
163
215
  message << " arguments: #{expected_arguments}" if expected_arguments
164
216
  message << " in: #{expected_interval_output}" if expected_interval
165
217
  message << " at: #{expected_timestamp}" if expected_timestamp
@@ -18,13 +18,11 @@ module RSpec
18
18
  # expect(AwesomeWorker).to have_enqueued_sidekiq_job.in(5.minutes)
19
19
  #
20
20
  def have_enqueued_sidekiq_job
21
- HaveEnqueuedSidekiqJobs.new.once
22
- end
23
-
24
- def have_enqueued_sidekiq_jobs
25
21
  HaveEnqueuedSidekiqJobs.new
26
22
  end
27
23
 
24
+ alias_method :have_enqueued_sidekiq_jobs, :have_enqueued_sidekiq_job
25
+
28
26
  # Checks if a certain job was enqueued in a block.
29
27
  #
30
28
  # expect { AwesomeWorker.perform_async }
@@ -37,12 +35,10 @@ module RSpec
37
35
  # .to enqueue_sidekiq_job(AwesomeWorker).in(5.minutes)
38
36
  #
39
37
  def enqueue_sidekiq_job(worker_class)
40
- EnqueueSidekiqJobs.new(worker_class).once
41
- end
42
-
43
- def enqueue_sidekiq_jobs(worker_class)
44
38
  EnqueueSidekiqJobs.new(worker_class)
45
39
  end
40
+
41
+ alias_method :enqueue_sidekiq_jobs, :enqueue_sidekiq_job
46
42
  end
47
43
  end
48
44
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module SidekiqPro
5
- VERSION = "1.1.0"
5
+ VERSION = "1.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-sidekiq_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Savater Sebastien
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-16 00:00:00.000000000 Z
11
+ date: 2023-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -98,7 +98,7 @@ dependencies:
98
98
  - - "~>"
99
99
  - !ruby/object:Gem::Version
100
100
  version: '2.6'
101
- description:
101
+ description: A collection of RSpec matchers for Sidekiq Pro
102
102
  email: github.60k5k@simplelogin.co
103
103
  executables: []
104
104
  extensions: []
@@ -132,8 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubygems_version: 3.1.6
135
+ rubygems_version: 3.3.7
136
136
  signing_key:
137
137
  specification_version: 4
138
- summary: A collection of tools and matchers for Sidekiq Pro
138
+ summary: A collection of RSpec matchers for Sidekiq Pro
139
139
  test_files: []