Enable Matcher for path
lutzj82 opened this issue · 7 comments
I have a PUT request that takes uses a UUID as part of the path, but since the path argument is a String, I can't pass it a Matcher [String: AnyObject]
example of what I'd like to do:
let putReq = Matcher.term(matcher: "/^\\/v1\\/start\\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i",
generate: "/v1/start/\(uuid)/")
mockService.given("a record exists")
.uponReceiving("a request to invoke start action for new instance")
.withRequest(method:.PUT, path: putReq)
.willRespondWith(status:200)
@lutzj82 Hmm, that sounds like a problem. I should have time to look at it tomorrow.
@lutzj82 I pushed a fix to master. Let me know if it works for you.
I'm still using XCode 7.3 and swift 2 with Carthage, I'll have to see what you did.
@lutzj82 Although the change that I made "seems" to work from the consumer point of view, I noticed that the pact file generated is missing the matcher details. It looks to be a bug in the mock service, and I've raised a bug there pact-foundation/pact-mock_service#55 This may mean that what you are trying to achieve won't work until that bug is fixed.
As a side note, I am currently working at removing the dependency on the ruby mock service in favour of a native library. The native mock service will be the path forward for most of the pact clients and should not have this problem.
@lutzj82 OK, it seems I am wrong, and it is working as designed. Let me know if you would like me to retrofit the fix back for swift 2.2
@andrewspinks, So I took your code changes and added it as an extension method on my end and it worked! If you could, that'd be great as I wasn't planning on the upgrade for a little while. If not, I will use the extension until then.
@lutzj82 Awesome! I'll try and retrofit it sometime this week. I'll leave this open until I've released the new version.