Sha256: 1670c394c924f384dbd2243238c8ab6714d8e537b19cfc284675f52b9a591175

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

require "test_helper"

class TestScheduler < Minitest::Test
  def logger
    @logger ||= begin
      l = Logger.new(STDOUT)
      l.level = Logger::UNKNOWN
      l
    end
  end

  def test_scheduler
    test_one_counter = 0
    test_two_counter = 0

    Zhong.logger = logger

    Zhong.schedule do
      every(10.seconds, "test_one") { test_one_counter += 1 }
      every(3.seconds, "test_two") { test_two_counter += 1 }
    end

    t = Thread.new { Zhong.start }
    sleep(7)
    Zhong.stop
    t.join
    assert_equal 1, test_one_counter
    assert_equal 3, test_two_counter
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zhong-0.1.5 test/scheduler_test.rb