spec/timers_spec.rb in timers-1.0.2 vs spec/timers_spec.rb in timers-1.1.0

- old
+ new

@@ -1,9 +1,9 @@ require 'spec_helper' describe Timers do - # Level of accuracy enforced by the tests (50ms) + # Level of accuracy enforced by most tests (50ms) Q = 0.05 it "sleeps until the next timer" do interval = Q * 2 started_at = Time.now @@ -59,8 +59,19 @@ result.should == [:foo] sleep Q * 5 subject.fire result.should == [:foo, :foo] + end + end + + describe "millisecond timers" do + it "calculates the proper interval to wait until firing" do + interval_ms = 25 + + subject.after_milliseconds(interval_ms) + expected_elapse = subject.wait_interval + + subject.wait_interval.should be_within(Q).of (interval_ms / 1000.0) end end end