test/test_helper.rb in resque-scheduler-2.5.5 vs test/test_helper.rb in resque-scheduler-3.0.0
- old
+ new
@@ -1,59 +1,50 @@
-# Pretty much copied this file from the resque test_helper since we want
-# to do all the same stuff
+# vim:fileencoding=utf-8
+require 'simplecov'
-dir = File.dirname(File.expand_path(__FILE__))
-
-require 'rubygems'
-require 'bundler/setup'
-
-require 'simplecov' unless RUBY_VERSION < '1.9'
-
require 'test/unit'
require 'mocha/setup'
+require 'rack/test'
require 'resque'
$LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__)) + '/../lib'
-require 'resque_scheduler'
-require 'resque_scheduler/server'
+require 'resque-scheduler'
+require 'resque/scheduler/server'
unless ENV['RESQUE_SCHEDULER_DISABLE_TEST_REDIS_SERVER']
# Start our own Redis when the tests start. RedisInstance will take care of
# starting and stopping.
require File.expand_path('../support/redis_instance', __FILE__)
RedisInstance.run!
end
-at_exit do
- next if $!
+at_exit { exit MiniTest::Unit.new.run(ARGV) || 0 }
- if defined?(MiniTest)
- exit_code = MiniTest::Unit.new.run(ARGV)
- else
- exit_code = Test::Unit::AutoRunner.run
- end
-
- exit(exit_code || 0)
-end
-
##
# test/spec/mini 3
-# http://gist.github.com/25455
-# chris@ozmm.org
+# original work: http://gist.github.com/25455
+# forked and modified: https://gist.github.com/meatballhat/8906709
#
def context(*args, &block)
return super unless (name = args.first) && block
require 'test/unit'
- klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
+ klass = Class.new(Test::Unit::TestCase) do
def self.test(name, &block)
- define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
+ define_method("test_#{name.gsub(/\W/, '_')}", &block) if block
end
- def self.xtest(*args) end
- def self.setup(&block) define_method(:setup, &block) end
- def self.teardown(&block) define_method(:teardown, &block) end
+ def self.xtest(*_args)
+ end
+ def self.setup(&block)
+ define_method(:setup, &block)
+ end
+ def self.teardown(&block)
+ define_method(:teardown, &block)
+ end
end
- (class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') }
+ (class << klass; self end).send(:define_method, :name) do
+ name.gsub(/\W/, '_')
+ end
klass.class_eval(&block)
end
unless defined?(Rails)
module Rails
@@ -62,20 +53,20 @@
end
end
end
class FakeCustomJobClass
- def self.scheduled(queue, klass, *args); end
+ def self.scheduled(_queue, _klass, *_args); end
end
class FakeCustomJobClassEnqueueAt
@queue = :test
- def self.scheduled(queue, klass, *args); end
+ def self.scheduled(_queue, _klass, *_args); end
end
class SomeJob
- def self.perform(repo_id, path)
+ def self.perform(_repo_id, _path)
end
end
class SomeIvarJob < SomeJob
@queue = :ivar
@@ -85,10 +76,16 @@
def self.queue
:fancy
end
end
+class SomeSharedEnvJob < SomeJob
+ def self.queue
+ :shared_job
+ end
+end
+
class SomeQuickJob < SomeJob
@queue = :quick
end
class SomeRealClass
@@ -108,23 +105,23 @@
%w(
APP_NAME
DYNAMIC_SCHEDULE
LOGFILE
LOGFORMAT
- MUTE
+ QUIET
RAILS_ENV
RESQUE_SCHEDULER_INTERVAL
VERBOSE
).each do |envvar|
ENV[envvar] = nil
end
def nullify_logger
Resque::Scheduler.configure do |c|
- c.mute = nil
+ c.quiet = nil
c.verbose = nil
c.logfile = nil
- c.logger = nil
+ c.send(:logger=, nil)
end
ENV['LOGFILE'] = nil
end