spec/gc_spec.rb in wayfarer-0.4.0 vs spec/gc_spec.rb in wayfarer-0.4.1

- old
+ new

@@ -4,17 +4,17 @@ describe Wayfarer::GC, redis: true do include Wayfarer::Redis::Connection let(:task) { build(:task) } - let(:klass) { Struct.new(:arguments) } - let(:job) { klass.new([task]) } + let(:klass) { Class.new(Wayfarer::Base) } + let(:job) { klass.new } subject(:gc) { Wayfarer::GC.new(job) } before do - allow(klass).to receive(:run_after_batch_callbacks) - task.barrier.seen?("https://example.com") + job.arguments = [task] + task.barrier.seen?(task.url) end describe "#run" do context "when counter reaches 0" do before { task.counter.increment } @@ -30,11 +30,13 @@ gc.run }.to change { redis { |conn| conn.exists?(task.counter.redis_key) } }.to(false) end it "runs after batch callbacks" do - expect(klass).to receive(:run_after_batch_callbacks).exactly(:once) - gc.run + expect { |spy| + klass.after_batch(&spy) + gc.run + }.to yield_control end end context "when counter does not reach 0" do before { 2.times { task.counter.increment } }