Sha256: 793b83a2e3186529b8f7b282d3eb8c29cf69957757dabdabefb9af431f0d92f9
Contents?: true
Size: 901 Bytes
Versions: 2
Compression:
Stored size: 901 Bytes
Contents
require File.dirname(__FILE__) + '/../lib/stalker' require 'contest' require 'mocha' module Stalker def log(msg); end def log_error(msg); end end class StalkerTest < Test::Unit::TestCase setup do Stalker.clear! $result = -1 $handled = false end test "enqueue and work a job" do val = rand(999999) Stalker.job('my.job') { |args| $result = args['val'] } Stalker.enqueue('my.job', :val => val) Stalker.prep Stalker.work_one_job assert_equal val, $result end test "invoke error handler when defined" do Stalker.error { |e| $handled = true } Stalker.job('my.job') { fail } Stalker.enqueue('my.job') Stalker.prep Stalker.work_one_job assert_equal true, $handled end test "continue working when error handler not defined" do Stalker.job('my.job') { fail } Stalker.enqueue('my.job') Stalker.prep Stalker.work_one_job assert_equal false, $handled end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stalker-0.4.2 | test/stalker_test.rb |
stalker-0.4.1 | test/stalker_test.rb |