Sha256: fc530ac7b2064834644a0e72e8e046935f46b4c15c3cce0083049d0cc1bad31a

Contents?: true

Size: 931 Bytes

Versions: 6

Compression:

Stored size: 931 Bytes

Contents

#
# Testing the 'rufus-scheduler'
#
# John Mettraux at openwfe.org
#
# Sat Jan 26 20:05:57 JST 2008
#

require 'test/unit'
require 'rufus/scheduler'


class Scheduler5Test < Test::Unit::TestCase

  #def setup
  #end

  #def teardown
  #end

  #
  # Testing the :first_at parameter
  #
  def test_0

    s = Rufus::Scheduler.new
    s.start

    $count = 0

    fa = Time.now + 3

    s.schedule_every "1s", :first_at => fa do
      $count += 1
    end

    sleep 1

    assert_equal 0, $count

    sleep 3

    assert_equal 1, $count

    sleep 1

    assert_equal 2, $count

    s.stop
  end

  #
  # Testing the :first_in parameter
  #
  def test_1

    s = Rufus::Scheduler.new
    s.start

    $count = 0

    s.schedule_every "1s", :first_in => "3s" do
      $count += 1
    end

    sleep 1

    assert_equal 0, $count

    sleep 3

    assert_equal 1, $count

    sleep 1

    assert_equal 2, $count

    s.stop
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rufus-scheduler-1.0.9 test/scheduler_5_test.rb
rufus-scheduler-1.0.8 test/scheduler_5_test.rb
rufus-scheduler-1.0.6 test/scheduler_5_test.rb
rufus-scheduler-1.0.11 test/scheduler_5_test.rb
rufus-scheduler-1.0.7 test/scheduler_5_test.rb
rufus-scheduler-1.0.10 test/scheduler_5_test.rb