Sha256: 05dc3d4837a6f6e6d1f1eb55a4c81d1de5f7d466b1eca52a988e1e7d9c890f7b
Contents?: true
Size: 551 Bytes
Versions: 2
Compression:
Stored size: 551 Bytes
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe Proc do describe '#throttle' do it 'should throttle proc call' do count = 0 proc = Proc.new do |increment| count += increment || 1 end throttled_proc = proc.throttle(1) 10.times do throttled_proc.call end sleep 1.1 count.should eql(1) throttled_proc.call sleep 1.1 count.should eql(2) throttled_proc.call(10) sleep 1.1 count.should eql(12) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
proc-throttle-0.0.2 | spec/throttle_spec.rb |
proc-throttle-0.0.1 | spec/throttle_spec.rb |