-
Notifications
You must be signed in to change notification settings - Fork 216
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
Allow parts of request to be changed by provider state #161
Comments
I believe this feature is part of the v4 spec. Is that right @uglyog? |
I think you are referring to generators from the V3 spec, but they are independent of the provider states. It makes sense that the generators should not be tied to the implementation of the provider state, as that could introduce coupling to setup in the generators behaviour. But if we have a specific type of generator that is explicit in that it is based on the provider state, that would be really useful. I have also been thinking of introducing references to the pact files (as in the |
Hi @uglyog, thanks for the info. So, is this something that could be added to a future version of Pact? And if so, would it be possible for me to submit this as a pull request, if I made some changes that make it more in line with what you were planning on doing? We'd like to use this for our Pact setup, and it seems like some other Pact users have run into similar needs, like in issues #49 and #84. |
PR's are always welcome, it's how the open-source world is built. |
Hi Pact,
I have an idea for a new feature, with a working implementation that I'd like your input on. It's something that solves a lot of problems we were running into when trying to use Pact.
In short, it allows you to specify values in the contract that won't be filled in until the provider state set up runs. This is useful for putting things like object IDs in the URL. I've been calling it "provider parameters."
You can specify a parameter like this:
And then, in your provider state, set a different
animal_id
value like this:So when you run it against the mock service provider, the request will be
/animals/7/profile
, but when you run the verify step against a real provider, it would use the actual ID of the animal that was created in your provider state.I've forked this repository at https://github.com/tucker-m/pact-ruby, with a README.md explaining how to use it with some examples. The commit history is a mess right now, but I'd be glad to clean that up if this is something you would be interested in as a pull request.
I've love to hear any feedback you have about this concept and answer any questions about it.
Thanks,
-Tucker
The text was updated successfully, but these errors were encountered: