Sha256: cc4556eacbe5a10f6b0bb5f9eb19add74673af33732ff248e71dd5da832e9fcf
Contents?: true
Size: 831 Bytes
Versions: 4
Compression:
Stored size: 831 Bytes
Contents
# frozen_string_literal: true require "spec_helper" describe Lita::Timer do let(:queue) { Queue.new } before { allow(subject).to receive(:sleep) } after { subject.stop } it "runs single timers" do subject = described_class.new { queue.push(true) } expect(subject).to receive(:sleep).with(0).once subject.start expect(queue.pop(true)).to be(true) expect { queue.pop(true) }.to raise_error(ThreadError) end it "runs recurring timers" do halt = false subject = described_class.new(interval: 1, recurring: true) do |timer| queue.push(true) timer.stop if halt halt = true end expect(subject).to receive(:sleep).with(1).twice subject.start 2.times { expect(queue.pop(true)).to be(true) } expect { queue.pop(true) }.to raise_error(ThreadError) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rita-5.0.0.alpha.4 | spec/lita/timer_spec.rb |
rita-5.0.0.alpha.3 | spec/lita/timer_spec.rb |
rita-5.0.0.alpha.2 | spec/lita/timer_spec.rb |
rita-5.0.0.alpha.1 | spec/lita/timer_spec.rb |