Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging robustness #104

Merged
merged 11 commits into from
May 30, 2019
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