Sha256: 78fba44f3fd7dfe011109ac45985cf87c75142ae53e6b10b5cd8be405a4c1754
Contents?: true
Size: 985 Bytes
Versions: 22
Compression:
Stored size: 985 Bytes
Contents
require "helper" require "flipper/adapters/sync/interval_synchronizer" RSpec.describe Flipper::Adapters::Sync::IntervalSynchronizer do let(:events) { [] } let(:synchronizer) { -> { events << described_class.now } } let(:interval) { 10 } 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 now = described_class.now subject.call events.clear # move time to one millisecond less than last sync + interval 1.upto(interval) do |i| allow(described_class).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(described_class).to receive(:now).and_return(now + interval) subject.call expect(events.size).to be(1) end end
Version data entries
22 entries across 22 versions & 1 rubygems
Version | Path |
---|---|
flipper-0.16.1 | spec/flipper/adapters/sync/interval_synchronizer_spec.rb |
flipper-0.16.0 | spec/flipper/adapters/sync/interval_synchronizer_spec.rb |