Skip to content

Commit c9abf3c

Browse files
phigginsdefunkt
authored andcommitted
Fix tests for 1.9.2.
1 parent 7b6f3e9 commit c9abf3c

File tree

8 files changed

+27
-18
lines changed

8 files changed

+27
-18
lines changed

Rakefile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#
44

55
load 'tasks/redis.rake'
6-
require 'rake/testtask'
76

87
$LOAD_PATH.unshift 'lib'
98
require 'resque/tasks'
@@ -17,14 +16,22 @@ end
1716
# Tests
1817
#
1918

19+
require 'rake/testtask'
20+
2021
task :default => :test
2122

22-
desc "Run the test suite"
23-
task :test do
24-
rg = command?(:rg)
25-
Dir['test/**/*_test.rb'].each do |f|
26-
rg ? sh("rg #{f}") : ruby(f)
23+
if command?(:rg)
24+
desc "Run the test suite with rg"
25+
task :test do
26+
Dir['test/**/*_test.rb'].each do |f|
27+
sh("rg #{f}")
28+
end
2729
end
30+
else
31+
Rake::TestTask.new do |test|
32+
test.libs << "test"
33+
test.test_files = FileList['test/**/*_test.rb']
34+
end
2835
end
2936

3037
if command? :kicker

test/job_hooks_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.dirname(__FILE__) + '/test_helper'
1+
require 'test_helper'
22

33
context "Resque::Job before_perform" do
44
include PerformJob

test/job_plugins_test.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.dirname(__FILE__) + '/test_helper'
1+
require 'test_helper'
22

33
context "Multiple plugins with multiple hooks" do
44
include PerformJob
@@ -45,7 +45,7 @@ def before_perform1(history)
4545
end
4646
end
4747

48-
class ::BeforePerformJob
48+
class ::JobPluginsTestBeforePerformJob
4949
extend BeforePerformPlugin
5050
def self.perform(history)
5151
history << :perform
@@ -56,7 +56,7 @@ def self.before_perform(history)
5656
end
5757

5858
test "before_perform hooks are executed in order" do
59-
result = perform_job(BeforePerformJob, history=[])
59+
result = perform_job(JobPluginsTestBeforePerformJob, history=[])
6060
assert_equal true, result, "perform returned true"
6161
assert_equal [:before_perform, :before_perform1, :perform], history
6262
end
@@ -71,7 +71,7 @@ def after_perform_record_history(history)
7171
end
7272
end
7373

74-
class ::AfterPerformJob
74+
class ::JobPluginsTestAfterPerformJob
7575
extend AfterPerformPlugin
7676
def self.perform(history)
7777
history << :perform
@@ -82,7 +82,7 @@ def self.after_perform(history)
8282
end
8383

8484
test "after_perform hooks are executed in order" do
85-
result = perform_job(AfterPerformJob, history=[])
85+
result = perform_job(JobPluginsTestAfterPerformJob, history=[])
8686
assert_equal true, result, "perform returned true"
8787
assert_equal [:perform, :after_perform, :after_perform1], history
8888
end
@@ -111,7 +111,7 @@ def self.perform(history)
111111
assert_equal [:around_perform_plugin1, :perform], history
112112
end
113113

114-
class ::AroundPerformJob
114+
class ::JobPluginsTestAroundPerformJob
115115
extend AroundPerformPlugin1
116116
def self.perform(history)
117117
history << :perform
@@ -123,7 +123,7 @@ def self.around_perform(history)
123123
end
124124

125125
test "around_perform hooks are executed in order" do
126-
result = perform_job(AroundPerformJob, history=[])
126+
result = perform_job(JobPluginsTestAroundPerformJob, history=[])
127127
assert_equal true, result, "perform returned true"
128128
assert_equal [:around_perform, :around_perform_plugin1, :perform], history
129129
end

test/plugin_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.dirname(__FILE__) + '/test_helper'
1+
require 'test_helper'
22

33
context "Resque::Plugin finding hooks" do
44
module SimplePlugin

test/resque-web_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.dirname(__FILE__) + '/test_helper'
1+
require 'test_helper'
22
require 'resque/server/test_helper'
33

44
# Root path test

test/resque_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.dirname(__FILE__) + '/test_helper'
1+
require 'test_helper'
22

33
context "Resque" do
44
setup do

test/test_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def self.teardown(&block) define_method(:teardown, &block) end
6666
end
6767
(class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
6868
klass.class_eval &block
69+
# XXX: In 1.8.x, not all tests will run unless anonymous classes are kept in scope.
70+
($test_classes ||= []) << klass
6971
end
7072

7173
##

test/worker_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require File.dirname(__FILE__) + '/test_helper'
1+
require 'test_helper'
22

33
context "Resque::Worker" do
44
setup do

0 commit comments

Comments
 (0)