test/helper.rb in sidetiq-0.3.7 vs test/helper.rb in sidetiq-0.4.0.rc1

- old
+ new

@@ -1,20 +1,31 @@ if RUBY_PLATFORM != "java" require 'coveralls' Coveralls.wear! end -require 'minitest/autorun' -require 'mocha/setup' -require 'rack/test' - require 'sidekiq' require 'sidekiq/testing' +require 'minitest' +require 'mocha/setup' +require 'rack/test' + require 'sidetiq' require 'sidetiq/web' +require 'sidetiq/lock/watcher' +class Sidetiq::Supervisor + def self.clock + @clock ||= Sidetiq::Clock.new + end + + def self.handler + Sidetiq::Handler.new + end +end + # Keep the test output clean. Sidetiq.logger = Logger.new(nil) Dir[File.join(File.dirname(__FILE__), 'fixtures/**/*.rb')].each do |fixture| require fixture @@ -32,17 +43,17 @@ pushed = raw_push_old([payload]) if payload pushed ? payload['jid'] : nil end end -class Sidetiq::TestCase < MiniTest::Unit::TestCase +class Sidetiq::TestCase < MiniTest::Test def setup Sidekiq.redis { |r| r.flushall } end def clock - @clock ||= Sidetiq::Clock.instance + Sidetiq.clock end # Blatantly stolen from Sidekiq's test suite. def add_retry(worker = 'SimpleWorker', jid = 'bob', at = Time.now.to_f) payload = Sidekiq.dump_json('class' => worker, @@ -53,5 +64,9 @@ conn.zadd('retry', at.to_s, payload) end end end +# Override Celluloid's at_exit hook manually. +at_exit { + exit Minitest.run(ARGV) || false +}