Sha256: 041d61920c7edeca215e97f93e9df89314fb984e56568fa77ab3ac4d59d9e9d4
Contents?: true
Size: 986 Bytes
Versions: 2
Compression:
Stored size: 986 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_ms } } 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 milliseconds" do now = described_class.now_ms 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_ms).and_return(now + i - 1) subject.call end expect(events.size).to be(0) # move time to last sync + interval allow(described_class).to receive(:now_ms).and_return(now + interval) subject.call expect(events.size).to be(1) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flipper-0.13.0 | spec/flipper/adapters/sync/interval_synchronizer_spec.rb |
flipper-0.13.0.beta1 | spec/flipper/adapters/sync/interval_synchronizer_spec.rb |