resque_spec 0.12.4 → 0.12.5

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.
data/README.md CHANGED
@@ -327,26 +327,28 @@ Follow me on [Github](https://github.com/leshill) and
327
327
  Contributors
328
328
  ============
329
329
 
330
- * @kennethkalmer (Kenneth Kalmer) : rspec dependency fix
331
- * @bcardarella (Brian Cardarella) : fix mutation bug
332
- * @joshdavey (Joshua Davey) : with\_resque helper
333
- * @supaspoida (Lar Van Der Jagt) : with\_resque helper
334
- * @evansagge (Evan Sagge) : Hook in via Job.create, have\_queued.in
335
- * @l4rk (Jon Larkowski) : inline perform
336
- * @jcf (James Conroy-Finn) : spec fix
337
- * @ess (Dennis Walters) : enqueue\_in support
338
- * @RipTheJacker : remove\_delayed support
339
- * @kwerle (Kurt Werle) : explicit require spec for v020
340
- * @dwilkie : initial before\_enqueue support
341
- * @marcinb (Marcin Balinski) : have\_schedule\_size\_of matcher, schedule matcher at, in
342
- * @alexeits : fix matcher in bug with RSpec 2.8.0
343
- * @ToadJamb : encode/decode of Resque job arguments
344
- * @mkonikowski (Mateusz Konikowski) : support for anything matcher
345
- * @mathieuravaux (Mathieu Ravaux) : without\_resque\_spec support
346
- * @avdgaag (Arjan van der Gaag) : peek support
347
- * @dtsiknis : Updated removed\_delayed
348
- * @lellisga (Li Ellis Gallardo) : fix inline/disable\_ext bug
349
- * @jeffdeville (Jeff Deville) : Resque.size
330
+ * @kennethkalmer (Kenneth Kalmer) :rspec dependency fix
331
+ * @bcardarella (Brian Cardarella) :fix mutation bug
332
+ * @joshdavey (Joshua Davey) :with\_resque helper
333
+ * @supaspoida (Lar Van Der Jagt) :with\_resque helper
334
+ * @evansagge (Evan Sagge) :Hook in via Job.create, have\_queued.in
335
+ * @l4rk (Jon Larkowski) :inline perform
336
+ * @jcf (James Conroy-Finn) :spec fix
337
+ * @ess (Dennis Walters) :enqueue\_in support
338
+ * @RipTheJacker :remove\_delayed support
339
+ * @kwerle (Kurt Werle) :explicit require spec for v020
340
+ * @dwilkie :initial before\_enqueue support
341
+ * @marcinb (Marcin Balinski) :have\_schedule\_size\_of matcher, schedule matcher at, in
342
+ * @alexeits :fix matcher in bug with RSpec 2.8.0
343
+ * @ToadJamb :encode/decode of Resque job arguments
344
+ * @mkonikowski (Mateusz Konikowski) :support for anything matcher
345
+ * @mathieuravaux (Mathieu Ravaux) :without\_resque\_spec support
346
+ * @avdgaag (Arjan van der Gaag) :peek support
347
+ * @dtsiknis :Updated removed\_delayed
348
+ * @lellisga (Li Ellis Gallardo) :fix inline/disable\_ext bug
349
+ * @jeffdeville (Jeff Deville) :Resque.size
350
+ * @opinel (Frank Wambutt) :Fix DST problem in `have\_scheduled`
351
+ * @lukemelia (Luke Melia) :Add `times` chained matcher
350
352
 
351
353
  Copyright
352
354
  =========
@@ -27,20 +27,40 @@ end
27
27
  RSpec::Matchers.define :have_queued do |*expected_args|
28
28
  extend InQueueHelper
29
29
 
30
+ chain :times do |num_times_queued|
31
+ @times = num_times_queued
32
+ @times_info = @times == 1 ? ' once' : " #{@times} times"
33
+ end
34
+
35
+ chain :once do |num_times_queued|
36
+ @times = 1
37
+ @times_info = ' once'
38
+ end
39
+
30
40
  match do |actual|
31
- queue(actual).any? { |entry| entry[:class].to_s == actual.to_s && expected_args == entry[:args] }
41
+ matched = queue(actual).select do |entry|
42
+ klass = entry.fetch(:class)
43
+ args = entry.fetch(:args)
44
+ klass.to_s == actual.to_s && expected_args == args
45
+ end
46
+
47
+ if @times
48
+ matched.size == @times
49
+ else
50
+ matched.size > 0
51
+ end
32
52
  end
33
53
 
34
54
  failure_message_for_should do |actual|
35
- "expected that #{actual} would have [#{expected_args.join(', ')}] queued"
55
+ "expected that #{actual} would have [#{expected_args.join(', ')}] queued#{@times_info}"
36
56
  end
37
57
 
38
58
  failure_message_for_should_not do |actual|
39
- "expected that #{actual} would not have [#{expected_args.join(', ')}] queued"
59
+ "expected that #{actual} would not have [#{expected_args.join(', ')}] queued#{@times_info}"
40
60
  end
41
61
 
42
62
  description do
43
- "have queued arguments of [#{expected_args.join(', ')}]"
63
+ "have queued arguments of [#{expected_args.join(', ')}]#{@times_info}"
44
64
  end
45
65
  end
46
66
 
@@ -85,7 +105,7 @@ RSpec::Matchers.define :have_scheduled do |*expected_args|
85
105
  time_matches = if @time
86
106
  entry[:time] == @time
87
107
  elsif @interval
88
- entry[:time].to_i == entry[:stored_at].to_i + @interval
108
+ entry[:time].to_i == (entry[:stored_at] + @interval).to_i
89
109
  else
90
110
  true
91
111
  end
@@ -1,3 +1,3 @@
1
1
  module ResqueSpec
2
- VERSION = "0.12.4"
2
+ VERSION = "0.12.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.4
4
+ version: 0.12.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-20 00:00:00.000000000 Z
12
+ date: 2012-11-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: resque