pact-foundation / pact-mock_service

Provides a mock service for use with Pact
https://pact.io
MIT License
73 stars 69 forks source link

Trailing slash of path gets removed when query parameter is used #66

Closed nickshoust-wf closed 7 years ago

nickshoust-wf commented 7 years ago

I have come across an issue when using a query parameter on the pact.with_request()

The issue is when your path has a trailing slash and you are including a query in your request

The resulting contract splits the path and query into separate keys under request but does not include the trailing slash as a part of the path.

I have included a link to a gist of an example test that generates a contract as well as the contract it generated in the comments

https://gist.github.com/nickshoust-wf/5850df10ec556632e8eee467f6819199

bethesque commented 7 years ago

I take it there is a difference in behaviour on the actual server when the slash is not included?

nickshoust-wf commented 7 years ago

Correct. I was expecting a 200 for the request if it had the slash before the query portion but was getting a 404 as there no handler for it.

bethesque commented 7 years ago

That server be weird :P I'll have a look in the code and see if the slash is being deliberately dropped anywhere.

bethesque commented 7 years ago

Well, look what we have here:

https://github.com/bethesque/pact-support/blob/d27def23b778503b7f3104ea87f9eb5a406d4801/lib/pact/shared/request.rb#L19

Looks like I've been meaning to get rid of that for a very long time. I remember now. I wanted to release all the breaking changes for version 2 together, but it had never made it to the top of the priority list. Let me have a think about what I can do.

bethesque commented 7 years ago

Ok, I've released a new version of the mock service gem (2.0.0, because it was a breaking change). Now you'll need to get the docker image updated.