Skip to content

Commit

Permalink
Merge pull request #104 from lextiz/patch-1
Browse files Browse the repository at this point in the history
feat: improve logging robustness for non utf-8 characters
  • Loading branch information
bethesque authored May 30, 2019
2 parents 3c26b46 + e3cd33f commit cfb0259
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/pact/mock_service/request_handlers/interaction_replay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ module RequestHandlers
module PrettyGenerate
#Doesn't seem to reliably pretty generate unless we go to JSON and back again :(
def pretty_generate object
JSON.pretty_generate(JSON.parse(object.to_json))
begin
JSON.pretty_generate(JSON.parse(object.to_json))
rescue
object.to_s
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,18 @@ module RequestHandlers
end
end
end

context "when the body contains special charachters" do
let(:actual_body) { '\xEB' }

let(:expected_response_body) do
{"message"=>"No interaction found for GET /path", "interaction_diffs"=>[{"body"=>{"ACTUAL"=>"\\xEB", "EXPECTED"=>{"a"=>"body"}}, "description"=>"a request"}]}
end

it "returns the specified response status" do
expect(response_status).to eq 500
end
end
end

context "when no request is found with a matching method and path" do
Expand Down

0 comments on commit cfb0259

Please sign in to comment.