resque_unit 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,9 +19,8 @@ module ResqueUnit::Assertions
19
19
  Resque.queue(queue_name)
20
20
  end
21
21
 
22
- assert_block (message || "#{klass}#{args ? " with #{args.inspect}" : ""} should have been queued in #{queue_name}: #{queue.inspect}.") do
23
- in_queue?(queue, klass, args)
24
- end
22
+ assert_with_custom_message(in_queue?(queue, klass, args),
23
+ message || "#{klass}#{args ? " with #{args.inspect}" : ""} should have been queued in #{queue_name}: #{queue.inspect}.")
25
24
  end
26
25
  alias assert_queues assert_queued
27
26
 
@@ -37,9 +36,8 @@ module ResqueUnit::Assertions
37
36
  Resque.queue(queue_name)
38
37
  end
39
38
 
40
- assert_block (message || "#{klass}#{args ? " with #{args.inspect}" : ""} should not have been queued in #{queue_name}.") do
41
- !in_queue?(queue, klass, args)
42
- end
39
+ assert_with_custom_message(!in_queue?(queue, klass, args),
40
+ message || "#{klass}#{args ? " with #{args.inspect}" : ""} should not have been queued in #{queue_name}.")
43
41
  end
44
42
 
45
43
  # Asserts no jobs were queued within the block passed.
@@ -52,6 +50,21 @@ module ResqueUnit::Assertions
52
50
 
53
51
  private
54
52
 
53
+ # In Test::Unit, +assert_block+ displays only the message on a test
54
+ # failure and +assert+ always appends a message to the end of the
55
+ # passed-in assertion message. In MiniTest, it's the other way
56
+ # around. This abstracts those differences and never appends a
57
+ # message to the one the user passed in.
58
+ def assert_with_custom_message(value, message = nil)
59
+ if defined?(MiniTest::Assertions)
60
+ assert value, message
61
+ else
62
+ assert_block message do
63
+ value
64
+ end
65
+ end
66
+ end
67
+
55
68
  def in_queue?(queue, klass, args = nil)
56
69
  !matching_jobs(queue, klass, args).empty?
57
70
  end
@@ -57,13 +57,7 @@ module Resque
57
57
  # 2. Check if new jobs were announced, and execute them.
58
58
  # 3. Repeat 3
59
59
  def full_run!
60
- until empty_queues?
61
- queues.each do |k, v|
62
- while job = v.shift
63
- job[:klass].perform(*job[:args])
64
- end
65
- end
66
- end
60
+ run! until empty_queues?
67
61
  end
68
62
 
69
63
  # Returns the size of the given queue
data/test/test_helper.rb CHANGED
@@ -3,3 +3,7 @@ require 'shoulda'
3
3
  require 'resque_unit'
4
4
  require 'sample_jobs'
5
5
 
6
+ # Fix shoulda under 1.9.2. See https://github.com/thoughtbot/shoulda/issues/issue/117
7
+ unless defined?(Test::Unit::AssertionFailedError)
8
+ Test::Unit::AssertionFailedError = MiniTest::Assertion
9
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_unit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Weiss