diff --git a/lib/pact/shared/multipart_form_differ.rb b/lib/pact/shared/multipart_form_differ.rb index 7191f63..481d0f4 100644 --- a/lib/pact/shared/multipart_form_differ.rb +++ b/lib/pact/shared/multipart_form_differ.rb @@ -9,6 +9,8 @@ def self.call expected, actual, options = {} actual_boundary = actual.split.first actual_with_hardcoded_boundary = actual.gsub(actual_boundary, expected_boundary) TextDiffer.call(expected, actual_with_hardcoded_boundary, options) + rescue StandardError + TextDiffer.call(expected, actual, options) end end end diff --git a/spec/lib/pact/shared/multipart_form_differ_spec.rb b/spec/lib/pact/shared/multipart_form_differ_spec.rb index baed782..edd6d00 100644 --- a/spec/lib/pact/shared/multipart_form_differ_spec.rb +++ b/spec/lib/pact/shared/multipart_form_differ_spec.rb @@ -2,9 +2,7 @@ module Pact describe MultipartFormDiffer do - describe ".call" do - let(:expected_body) do "-------------RubyMultipartPost-1e4912957c7bb64de3c444568326663b\r\nContent-Disposition: form-data; name=\"file\"; filename=\"text.txt\"\r\nContent-Length: 14\r\nContent-Type: text/plain\r\nContent-Transfer-Encoding: binary\r\n\r\nThis is a file\r\n-------------RubyMultipartPost-1e4912957c7bb64de3c444568326663b--\r\n\r\n" end @@ -34,6 +32,18 @@ module Pact expect(subject).to_not eq({}) end end + + context "when the actual is the hash body of application/json request" do + let(:actual_body) do + { + "some" => "hash" + } + end + + it "doesn't blow up" do + subject + end + end end end end