resque_unit 0.4.8 → 1.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
data/test/test_helper.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  require 'rubygems'
2
- require 'shoulda'
2
+ require 'minitest/spec'
3
3
  require 'resque_unit'
4
+ require 'resque_unit_scheduler'
4
5
  require 'sample_jobs'
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
6
+ require 'minitest/autorun'
7
+ require 'pry-byebug'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 1.0.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Weiss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-12 00:00:00.000000000 Z
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -25,7 +25,49 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.4.6
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: fakeredis
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: resque
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: resque-scheduler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-byebug
29
71
  requirement: !ruby/object:Gem::Requirement
30
72
  requirements:
31
73
  - - ">="
@@ -39,7 +81,7 @@ dependencies:
39
81
  - !ruby/object:Gem::Version
40
82
  version: '0'
41
83
  - !ruby/object:Gem::Dependency
42
- name: shoulda
84
+ name: bundler
43
85
  requirement: !ruby/object:Gem::Requirement
44
86
  requirements:
45
87
  - - ">="
@@ -52,6 +94,20 @@ dependencies:
52
94
  - - ">="
53
95
  - !ruby/object:Gem::Version
54
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.0'
55
111
  description:
56
112
  email: justin@uberweiss.org
57
113
  executables: []
@@ -62,13 +118,12 @@ files:
62
118
  - README.md
63
119
  - lib/resque_unit.rb
64
120
  - lib/resque_unit/assertions.rb
65
- - lib/resque_unit/errors.rb
66
121
  - lib/resque_unit/helpers.rb
67
- - lib/resque_unit/plugin.rb
68
122
  - lib/resque_unit/resque.rb
69
- - lib/resque_unit/scheduler.rb
123
+ - lib/resque_unit/resque/test_extensions.rb
70
124
  - lib/resque_unit/scheduler_assertions.rb
71
125
  - lib/resque_unit_scheduler.rb
126
+ - test/redis_test.rb
72
127
  - test/resque_test.rb
73
128
  - test/resque_unit_scheduler_test.rb
74
129
  - test/resque_unit_test.rb
@@ -89,16 +144,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
144
  version: '0'
90
145
  required_rubygems_version: !ruby/object:Gem::Requirement
91
146
  requirements:
92
- - - ">="
147
+ - - ">"
93
148
  - !ruby/object:Gem::Version
94
- version: '0'
149
+ version: 1.3.1
95
150
  requirements: []
96
151
  rubyforge_project:
97
- rubygems_version: 2.2.2
152
+ rubygems_version: 2.2.5
98
153
  signing_key:
99
154
  specification_version: 4
100
- summary: Test::Unit support for resque job queueing
155
+ summary: Minitest and Test::Unit support for resque job queueing
101
156
  test_files:
157
+ - test/redis_test.rb
102
158
  - test/resque_test.rb
103
159
  - test/resque_unit_scheduler_test.rb
104
160
  - test/resque_unit_test.rb
@@ -1,17 +0,0 @@
1
- # Re-define errors in from Resque, in case the 'resque' gem was not loaded.
2
- module Resque
3
- # Raised whenever we need a queue but none is provided.
4
- unless defined?(NoQueueError)
5
- class NoQueueError < RuntimeError; end
6
- end
7
-
8
- # Raised when trying to create a job without a class
9
- unless defined?(NoClassError)
10
- class NoClassError < RuntimeError; end
11
- end
12
-
13
- # Raised when a worker was killed while processing a job.
14
- unless defined?(DirtyExit)
15
- class DirtyExit < RuntimeError; end
16
- end
17
- end
@@ -1,70 +0,0 @@
1
- # A copy of the original Resque:Plugin class from the "resque" gem
2
- # No need to redefine this class if the resque gem was already loaded
3
- unless defined?(Resque::Plugin)
4
-
5
- module Resque
6
- module Plugin
7
- extend self
8
-
9
- LintError = Class.new(RuntimeError)
10
-
11
- # Ensure that your plugin conforms to good hook naming conventions.
12
- #
13
- # Resque::Plugin.lint(MyResquePlugin)
14
- def lint(plugin)
15
- hooks = before_hooks(plugin) + around_hooks(plugin) + after_hooks(plugin)
16
-
17
- hooks.each do |hook|
18
- if hook =~ /perform$/
19
- raise LintError, "#{plugin}.#{hook} is not namespaced"
20
- end
21
- end
22
-
23
- failure_hooks(plugin).each do |hook|
24
- if hook =~ /failure$/
25
- raise LintError, "#{plugin}.#{hook} is not namespaced"
26
- end
27
- end
28
- end
29
-
30
- # Given an object, returns a list `before_perform` hook names.
31
- def before_hooks(job)
32
- job.methods.grep(/^before_perform/).sort
33
- end
34
-
35
- # Given an object, returns a list `around_perform` hook names.
36
- def around_hooks(job)
37
- job.methods.grep(/^around_perform/).sort
38
- end
39
-
40
- # Given an object, returns a list `after_perform` hook names.
41
- def after_hooks(job)
42
- job.methods.grep(/^after_perform/).sort
43
- end
44
-
45
- # Given an object, returns a list `on_failure` hook names.
46
- def failure_hooks(job)
47
- job.methods.grep(/^on_failure/).sort
48
- end
49
-
50
- # Given an object, returns a list `after_enqueue` hook names.
51
- def after_enqueue_hooks(job)
52
- job.methods.grep(/^after_enqueue/).sort
53
- end
54
-
55
- # Given an object, returns a list `before_enqueue` hook names.
56
- def before_enqueue_hooks(job)
57
- job.methods.grep(/^before_enqueue/).sort
58
- end
59
- end
60
- end
61
-
62
- end
63
-
64
- unless defined?(Resque::Job::DontPerform)
65
- module Resque
66
- class Job
67
- DontPerform = Class.new(StandardError)
68
- end
69
- end
70
- end
@@ -1,40 +0,0 @@
1
- module ResqueUnit
2
-
3
- # ResqueUnit::Scheduler is a group of functions mocking the behavior
4
- # of resque-scheduler. It is included into Resque when
5
- # 'resque_unit_scheduler' is required.
6
- module Scheduler
7
-
8
- # takes a timestamp which will be used to schedule the job
9
- # for queueing. Until timestamp is in the past, the job will
10
- # sit in the schedule list.
11
- def enqueue_at(timestamp, klass, *args)
12
- enqueue_with_timestamp(timestamp, klass, *args)
13
- end
14
-
15
- # Identical to enqueue_at but takes number_of_seconds_from_now
16
- # instead of a timestamp.
17
- def enqueue_in(number_of_seconds_from_now, klass, *args)
18
- enqueue_at(Time.now + number_of_seconds_from_now, klass, *args)
19
- end
20
-
21
- def enqueue_with_timestamp(timestamp, klass, *args)
22
- enqueue_unit(queue_for(klass), {"class" => klass.name, "args" => args, "timestamp" => timestamp})
23
- end
24
-
25
- def remove_delayed(klass, *args)
26
- # points to real queue
27
- encoded_job_payloads = Resque.queue(queue_for(klass))
28
- args ||= []
29
- encoded_job_payloads.delete_if { |e| e = Resque.decode(e); e["class"] == klass.to_s && e["args"] == args }
30
- end
31
-
32
- def remove_delayed_job_from_timestamp(timestamp, klass, *args)
33
- encoded_job_payloads = Resque.queue(queue_for(klass))
34
- args ||= []
35
- encoded_job_payloads.delete_if { |e| e = Resque.decode(e); e["class"] == klass.to_s && Time.parse(e["timestamp"]).to_i == Time.parse(timestamp.to_s).to_i && e["args"] == args }
36
- end
37
- end
38
-
39
- Resque.send(:extend, Scheduler)
40
- end