spec/gc_spec.rb in wayfarer-0.4.3 vs spec/gc_spec.rb in wayfarer-0.4.4

- old
+ new

@@ -4,16 +4,14 @@ describe Wayfarer::GC, redis: true do include Wayfarer::Redis::Connection let(:task) { build(:task) } - let(:klass) { Class.new(Wayfarer::Base) } - let(:job) { klass.new } - subject(:gc) { Wayfarer::GC.new(job) } + subject(:gc) { described_class.new(task) } before do - job.arguments = [task] + task.metadata.job = spy task.barrier.seen?(task.url) end describe "#run" do context "when counter reaches 0" do @@ -30,14 +28,12 @@ gc.run }.to change { redis { |conn| conn.exists?(task.counter.redis_key) } }.to(false) end it "runs after batch callbacks" do - expect { |spy| - klass.after_batch(&spy) - gc.run - }.to yield_control + 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 } } @@ -53,10 +49,10 @@ gc.run }.not_to(change { redis { |conn| conn.exists?(task.counter.redis_key) } }) end it "does not run after batch callbacks" do - expect(klass).not_to receive(:run_after_batch_callbacks) + expect(task.metadata.job).not_to receive(:run_callbacks).with(:batch) gc.run end end end end