Sha256: 7c0800701e6e70eb7e579467efd998447c7a22e04c0e41db3f021aad0e71ca20

Contents?: true

Size: 770 Bytes

Versions: 3

Compression:

Stored size: 770 Bytes

Contents

# frozen_string_literal: true

require "spec_helpers"

describe Wayfarer::Middleware::Normalize do
  let(:task) { build(:task) }
  subject { described_class.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",
       "invalid@url-net"]
    end

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wayfarer-0.4.6 spec/middleware/normalize_spec.rb
wayfarer-0.4.5 spec/middleware/normalize_spec.rb
wayfarer-0.4.4 spec/middleware/normalize_spec.rb