test/helper.rb in glutton_ratelimit-0.1.0 vs test/helper.rb in glutton_ratelimit-0.2.0

- old
+ new

@@ -1,21 +1,20 @@ -require 'rubygems' -require 'test/unit' - -$LOAD_PATH.unshift(File.dirname(__FILE__)) -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -require 'glutton_ratelimit' - -class Test::Unit::TestCase -end - -def timed_run ratelimiter, passes = 1 - before_last_invocation = 0 - start_time = Time.now - (passes * ratelimiter.executions + 1).times do |n| - ratelimiter.wait - before_last_invocation = Time.now - yield - end - before_last_invocation - start_time -end - +require 'rubygems' +require 'test/unit' + +$LOAD_PATH.unshift(File.dirname(__FILE__)) +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) +require 'glutton_ratelimit' + +class Test::Unit::TestCase +end + +def timed_run ratelimiter, passes = 1 + before_last_invocation = 0 + start_time = Time.now + ratelimiter.times(passes * ratelimiter.executions + 1) do + before_last_invocation = Time.now + yield + end + before_last_invocation - start_time +end +