diff --git a/lib/pact_broker/pacts/sort_content.rb b/lib/pact_broker/pacts/sort_content.rb index 1b161fcec..a412b5657 100644 --- a/lib/pact_broker/pacts/sort_content.rb +++ b/lib/pact_broker/pacts/sort_content.rb @@ -29,9 +29,14 @@ def self.verifiable_content_key_for pact_hash end end - def self.order_verifiable_content array - array_with_ordered_hashes = order_hash_keys(array) - array_with_ordered_hashes.sort{ |a, b| a.to_json <=> b.to_json } + def self.order_verifiable_content probably_array + # You never can tell what people will do... + if probably_array.is_a?(Array) + array_with_ordered_hashes = order_hash_keys(probably_array) + array_with_ordered_hashes.sort{ |a, b| a.to_json <=> b.to_json } + else + probably_array + end end end end diff --git a/spec/lib/pact_broker/pacts/sort_content_spec.rb b/spec/lib/pact_broker/pacts/sort_content_spec.rb index ca4304b51..f06758b05 100644 --- a/spec/lib/pact_broker/pacts/sort_content_spec.rb +++ b/spec/lib/pact_broker/pacts/sort_content_spec.rb @@ -39,6 +39,19 @@ module Pacts 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