spec/pause/redis/adapter_spec.rb in pause-0.2.1 vs spec/pause/redis/adapter_spec.rb in pause-0.4.0
- old
+ new
@@ -29,19 +29,25 @@
expect(set).to_not be_empty
expect(set.size).to eql(1)
expect(set[0].size).to eql(2)
end
- it 'should remove old key from a redis set' do
- time = Time.now
- expect(redis_conn).to receive(:zrem).with(tracked_key, [adapter.period_marker(resolution, time)])
-
- adapter.time_blocks_to_keep = 1
- Timecop.freeze time do
- adapter.increment(scope, identifier, Time.now.to_i)
+ context 'removing two elements' do
+ let(:to_delete) { 2 }
+ let(:time) { Time.now }
+ before do
+ adapter
+ to_delete.times do |t|
+ expect(redis_conn).to receive(:zrem).with(tracked_key, [adapter.period_marker(resolution, time + t)]).once
+ end
+ adapter.time_blocks_to_keep = 1
end
- Timecop.freeze time + (adapter.resolution + 1) do
- adapter.increment(scope, identifier, Time.now.to_i)
+ it 'should remove old elements' do
+ adapter.increment(scope, identifier, time.to_i)
+ to_delete.times do |t|
+ next_time = time + (adapter.resolution + t + 1)
+ adapter.increment(scope, identifier, next_time.to_i)
+ end
end
end
it 'sets expiry on key' do
expect(redis_conn).to receive(:expire).with(tracked_key, history)