Sha256: 1ea8e121b82bba94f18419b36c62d7d4177ead4878ae5897be5efc5ffd286f26
Contents?: true
Size: 1.45 KB
Versions: 12
Compression:
Stored size: 1.45 KB
Contents
require "pact_broker/pacts/sort_content" module PactBroker module Pacts describe SortContent do let(:pact_content_1) do { "a" => 1, "interactions" => [{ "a" => 1, "b" => 2 }, { "a" => [2, 1, 3], "b" => 3 }] } end let(:pact_content_2) do { "interactions" => [{ "b" => 3, "a" => [2, 1, 3]}, { "b" => 2, "a" => 1 }], "a" => 1 } end let(:expected_sorted_content) do '{"a":1,"interactions":[{"a":1,"b":2},{"a":[2,1,3],"b":3}]}' end it "sorts the interactions/messages and keys in a deterministic way" do expect(SortContent.call(pact_content_1).to_json).to eq(expected_sorted_content) expect(SortContent.call(pact_content_2).to_json).to eq(expected_sorted_content) end context "when there is no messages or interactions key" do let(:other_content) do { "z" => 1, "a" => 1, "b" => 1, } end it "does not change the content" do expect(SortContent.call(other_content)).to eq other_content end end context "when interactions is a string" do let(:other_content) do { "a" => 1, "interactions" => "interactions" } end it "does not blow up" do expect(SortContent.call(other_content)).to eq other_content end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems