Sha256: bd794d65cc47a9509dcfe9355816f82b337f1de984f732684b19b78a67394a71

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

#
# Testing Rufus
#
# John Mettraux at openwfe.org
#
# Sun Oct 29 16:18:25 JST 2006
#

$:.unshift(File.dirname(__FILE__) + '/../lib')

require 'test/unit'
require 'openwfe/util/scheduler'


class Scheduler3Test < Test::Unit::TestCase

  #
  # Testing tags
  #
  def test_0

    scheduler = Rufus::Scheduler.new
    scheduler.start

    value = nil

    scheduler.schedule_in "3s", :tags => "fish" do
      value = "fish"
    end

    sleep 0.300 # let the job get really scheduled

    assert_equal [], scheduler.find_jobs('deer')
    assert_equal 1, scheduler.find_jobs('fish').size

    scheduler.schedule "* * * * *", :tags => "fish" do
      value = "cron-fish"
    end
    scheduler.cron "* * * * *", :tags => "vegetable" do
      value = "daikon"
    end

    sleep 0.300 # let the jobs get really scheduled

    assert_equal 2, scheduler.find_jobs('fish').size
    #puts scheduler.find_jobs('fish')

    assert_equal(
      3,
      scheduler.all_jobs.size)
    assert_equal(
      [ "Rufus::CronJob", "Rufus::CronJob", "Rufus::AtJob" ],
      scheduler.all_jobs.collect { |j| j.class.name })

    scheduler.find_jobs('fish').each do |job|
      scheduler.unschedule(job.job_id)
    end

    sleep 0.300 # give it some time to unschedule

    assert_equal [], scheduler.find_jobs('fish')
    assert_equal 1, scheduler.find_jobs('vegetable').size

    scheduler.find_jobs('vegetable')[0].unschedule

    sleep 0.300 # give it some time to unschedule

    assert_equal 0, scheduler.find_jobs('vegetable').size
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rufus-scheduler-1.0.12 test/scheduler_3_test.rb