Sha256: b836dcc54c6dbf1ce655d56838bd39303a728cb8472bc53cab6f48e59e83c075
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
require File.expand_path("../helper", __FILE__) class WorkerTest < Test::Unit::TestCase def test_cooler cooled = false cooler = lambda { cooled = true } worker = new_worker [], :processor => lambda { |_| fail 'item found?' }, :cooler => cooler worker.work assert cooled end def test_custom_on_error_handler called = false error_handler = lambda do |exc| called = true assert_equal 'booya', exc.message end worker = new_worker [1], :processor => lambda { |_| raise 'booya' }, :error_handler => error_handler worker.work assert called end def test_default_error_handler processor = lambda do |item| raise item.to_s end worker = new_worker [1], :processor => processor begin worker.work rescue RuntimeError => err assert_equal '1', err.message else fail "no exception raised" end end def test_breaks_when_stopped called = false worker = nil processor = lambda do |item| fail "callback called multiple times" if called assert_equal 1, item called = true worker.stop end worker = new_worker [1, nil], :processor => processor worker.run assert called end def test_new_worker_is_not_working assert !new_worker.working? end def new_worker(queue = [], options = {}) options[:instrumenter] ||= NullInstrumenter.new Worker.new(queue, options) end class Worker include QueueKit::Worker end class NullInstrumenter def instrument(name, payload = nil) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
queue_kit-0.0.6 | test/worker_test.rb |