HEX
Server: Apache
System: Windows NT MAGNETO-ARM 10.0 build 22000 (Windows 10) AMD64
User: Michel (0)
PHP: 7.4.7
Disabled: NONE
Upload Files
File: C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/roadie-4.0.0/spec/lib/roadie/deduplicator_spec.rb
# frozen_string_literal: true

require "spec_helper"

module Roadie
  describe Deduplicator do
    it "removes identical pairs, keeping the last one" do
      input = [
        ["a", "1"],
        ["b", "2"],
        ["a", "3"],
        ["a", "1"],
      ]

      expect(Deduplicator.apply(input)).to eq [
        ["b", "2"],
        ["a", "3"],
        ["a", "1"],
      ]
    end

    it "returns input when no duplicates are present" do
      input = [
        ["a", "1"],
        ["a", "3"],
        ["a", "2"],
      ]

      expect(Deduplicator.apply(input)).to eq input
    end
  end
end