Sha256: d07616a31b06d9459b3f30412a78ef3f39cf754daa0690f1d61bda3d55d20c3b

Contents?: true

Size: 776 Bytes

Versions: 4

Compression:

Stored size: 776 Bytes

Contents

# frozen_string_literal: true

require "spec_helpers"

describe Wayfarer::Middleware::Normalize do
  let(:task) { build(:task) }
  subject(:normalize) { Wayfarer::Middleware::Normalize.new }

  describe "#call" do
    let(:urls) do
      ["http://example.com/products?product_id=123",
       "HTTP://EXAMPLE.COM/products/?product_id=123",
       "http://example.com/products/?product_id=123",
       "http://example.com/foo/../products?product_id=123"]
    end

    before { task.metadata.staged_urls = SortedSet.new(urls) }

    it "yields" do
      expect { |spy| normalize.call(task, &spy) }.to yield_control
    end

    it "normalizes and compacts URLs" do
      normalize.call(task)
      expect(task.metadata.staged_urls).to eq(SortedSet[urls.first])
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wayfarer-0.4.3 spec/middleware/normalize_spec.rb
wayfarer-0.4.2 spec/middleware/normalize_spec.rb
wayfarer-0.4.1 spec/middleware/normalize_spec.rb
wayfarer-0.4.0 spec/middleware/normalize_spec.rb