Sha256: fd6a9ae809d94cd2d1ab062d12e88554f4077b7532bfd53c1821f98b3d5deb55
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
require File.dirname(__FILE__) + '/helper' class TestTimer < Test::Unit::TestCase def setup @t = Timer.new end def test_new_timer_should_have_no_events assert_equal 0, @t.events.size end def test_register_should_queue_event Time.stubs(:now).returns(0) w = Watch.new(nil) @t.register(w, stub(:interval => 20), nil) assert_equal 1, @t.events.size assert_equal w, @t.events.first.watch end def test_timer_should_remove_expired_events @t.register(nil, stub(:interval => 0), nil) sleep(0.3) assert_equal 0, @t.events.size end def test_timer_should_remove_only_expired_events @t.register(nil, stub(:interval => 0), nil) @t.register(nil, stub(:interval => 1000), nil) sleep(0.3) assert_equal 1, @t.events.size end def test_timer_should_sort_timer_events @t.register(nil, stub(:interval => 1000), nil) @t.register(nil, stub(:interval => 800), nil) @t.register(nil, stub(:interval => 900), nil) @t.register(nil, stub(:interval => 100), nil) sleep(0.3) assert_equal [100, 800, 900, 1000], @t.events.map { |x| x.condition.interval } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
god-0.1.0 | test/test_timer.rb |