Sha256: e7fce2355b4990438bde2d73d9858c12136920a97ffe2f7678804ace1c948ed5
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
# frozen_string_literal: true require "spec_helpers" describe Wayfarer::Middleware::Stage do let(:task) { build(:task) } subject { described_class.new } describe "#call" do it "assigns an empty set" do subject.call(task) expect(task.metadata.staged_urls).to eq(SortedSet.new) end it "yields" do expect { |spy| subject.call(task, &spy) }.to yield_control end it "enqueues tasks" do urls = [test_app_path("/alpha"), test_app_path("/beta")] spy.tap do |job| expect(job).to receive(:crawl).with(urls.first, batch: task.batch).ordered expect(job).to receive(:crawl).with(urls.second, batch: task.batch).ordered task.metadata.job = double(class: job) end subject.call(task) do task.metadata.staged_urls = SortedSet.new(urls) end end it "resets staged URLs" do task.metadata.staged_urls = SortedSet.new([test_app_path("/foo")]) expect { subject.call(task) }.to change { task.metadata.staged_urls.count }.to(0) end end describe described_class::API do subject(:controller) do Struct.new(:task).include(described_class).new(task) end describe "#stage" do before { task.metadata.staged_urls = SortedSet.new } it "stages URLs" do expect { controller.stage(test_app_path("/foo")) }.to change { task.metadata.staged_urls.count }.by(1) end it "converts to strings" do controller.stage(Addressable::URI.parse(test_app_path("/foo"))) expect(task.metadata.staged_urls.to_a.first).to be_a(String) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wayfarer-0.4.6 | spec/middleware/stage_spec.rb |
wayfarer-0.4.5 | spec/middleware/stage_spec.rb |
wayfarer-0.4.4 | spec/middleware/stage_spec.rb |