Sha256: 26dc842aca81f7270880050181bceb070887ce91c2aa4adf506cfea73202d2d3

Contents?: true

Size: 814 Bytes

Versions: 10

Compression:

Stored size: 814 Bytes

Contents

require 'spec_helper'

RSpec.describe Timers::Group do
	it "should not diverge too much" do
		fired = :not_fired_yet
		count = 0
		quantum = 0.01
		
		start_offset = subject.current_offset
		Timers::Timer.new(subject, quantum, :strict, start_offset) do |offset|
			fired = offset
			count += 1
		end
		
		iterations = 1000
		subject.wait while count < iterations
		
		# In my testing on the JVM, without the :strict recurring, I noticed 60ms of error here.
		expect(fired - start_offset).to be_within(quantum).of(iterations * quantum)
	end
	
	it "should only fire once" do
		fired = :not_fired_yet
		count = 0

		start_offset = subject.current_offset
		Timers::Timer.new(subject, 0, :strict, start_offset) do |offset|
			fired = offset
			count += 1
		end
		
		subject.wait
		
		expect(count).to be == 1
	end
end

Version data entries

10 entries across 8 versions & 4 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/timers-4.0.0/spec/strict_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/timers-4.0.0/spec/strict_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/timers-4.0.0/spec/strict_spec.rb
timers-4.0.4 spec/strict_spec.rb
timers-4.1.1 spec/strict_spec.rb
timers-4.1.0 spec/strict_spec.rb
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/timers-4.0.1/spec/strict_spec.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/timers-4.0.1/spec/strict_spec.rb
timers-4.0.1 spec/strict_spec.rb
timers-4.0.0 spec/strict_spec.rb