Sha256: bed80fbba60a2cdc524112dd82092ab4d6aed688f5905488565f1756d0bbd934
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
# frozen_string_literal: true require "spec_helpers" describe Wayfarer::GC, redis: true do include Wayfarer::Redis::Connection let(:task) { build(:task) } subject(:gc) { described_class.new(task) } before do task.metadata.job = spy task.barrier.seen?(task.url) end describe "#run" do context "when counter reaches 0" do before { task.counter.increment } it "resets the barrier" do expect { gc.run }.to change { redis { |conn| conn.exists?(task.barrier.redis_key) } }.to(false) end it "resets the counter" do expect { gc.run }.to change { redis { |conn| conn.exists?(task.counter.redis_key) } }.to(false) end it "runs after batch callbacks" do expect(task.metadata.job).to receive(:run_callbacks).with(:batch).exactly(:once) gc.run end end context "when counter does not reach 0" do before { 2.times { task.counter.increment } } it "does not reset the barrier" do expect { gc.run }.not_to(change { redis { |conn| conn.exists?(task.barrier.redis_key) } }) end it "does not reset the counter" do expect { gc.run }.not_to(change { redis { |conn| conn.exists?(task.counter.redis_key) } }) end it "does not run after batch callbacks" do expect(task.metadata.job).not_to receive(:run_callbacks).with(:batch) gc.run end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wayfarer-0.4.6 | spec/gc_spec.rb |
wayfarer-0.4.5 | spec/gc_spec.rb |
wayfarer-0.4.4 | spec/gc_spec.rb |