Sha256: fe21f5de7bcf29b96fbd98487d8e793be1405f7961528dc08f4bd057061777a1
Contents?: true
Size: 941 Bytes
Versions: 32
Compression:
Stored size: 941 Bytes
Contents
require "flipper/adapters/sync/interval_synchronizer" RSpec.describe Flipper::Adapters::Sync::IntervalSynchronizer do let(:events) { [] } let(:synchronizer) { -> { events << now } } let(:interval) { 10 } let(:now) { subject.send(:now) } subject { described_class.new(synchronizer, interval: interval) } it 'synchronizes on first call' do expect(events.size).to be(0) subject.call expect(events.size).to be(1) end it "only invokes wrapped synchronizer every interval seconds" do subject.call events.clear # move time to one millisecond less than last sync + interval 1.upto(interval) do |i| allow(subject).to receive(:now).and_return(now + i - 1) subject.call end expect(events.size).to be(0) # move time to last sync + interval in milliseconds allow(subject).to receive(:now).and_return(now + interval) subject.call expect(events.size).to be(1) end end
Version data entries
32 entries across 32 versions & 1 rubygems