Sha256: 7b383c2615a8c0c59a2295ce0320891cb493fdcf62d7297a5c9eb9bd2927656a
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
dir = File.dirname(File.expand_path(__FILE__)) $LOAD_PATH.unshift dir + '/../lib' $TESTING = true require 'rubygems' require 'minitest/unit' require 'minitest/pride' require 'rack/test' require 'mocha' if RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '1.9' require 'simplecov' SimpleCov.start do add_filter '/test/' end end require 'resque-retry' require dir + '/test_jobs' # make sure we can run redis if !system("which redis-server") puts '', "** can't find `redis-server` in your path" puts "** try running `sudo rake install`" abort '' end # start our own redis when the tests start, # kill it when they end at_exit do next if $! exit_code = MiniTest::Unit.new.run(ARGV) pid = `ps -e -o pid,command | grep [r]edis-test`.split(" ")[0] puts "Killing test redis server..." `rm -f #{dir}/dump.rdb` `kill -9 #{pid}` exit exit_code end puts "Starting redis for testing at localhost:9736..." `redis-server #{dir}/redis-test.conf` Resque.redis = '127.0.0.1:9736' # Mock failure backend for testing MultipleWithRetrySuppression class MockFailureBackend < Resque::Failure::Base class << self attr_accessor :errors end def save self.class.errors << exception.to_s end self.errors = [] end # Test helpers class MiniTest::Unit::TestCase def perform_next_job(worker, &block) return unless job = @worker.reserve @worker.perform(job, &block) @worker.done_working end def clean_perform_job(klass, *args) Resque.redis.flushall Resque.enqueue(klass, *args) worker = Resque::Worker.new(:testing) return false unless job = worker.reserve worker.perform(job) worker.done_working end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
resque-retry-1.0.0.a | test/test_helper.rb |