Hello, I am building out a POC and I using provide...
# pact-ruby
k
Hello, I am building out a POC and I using provider states to set up my data. I am trying to setup up my api to work with provider states. I am a bit confused by the direction here.
you will need to create a dev/test only HTTP endpoint that accepts a JSON document that looks like:
```{
"consumer": "CONSUMER_NAME",
"state": "PROVIDER_STATE"
}```
The following flag is required when running the CLI:
--provider-states-setup-url
- the full url of the endpoint which sets the active consumer and provider state.
Does my test only endpoint need to access a body in the request that I can pass in
CONSUMER_NAME
and
PROVIDER_STATE
or is the url just supposed to pass up those values as parameters in order to pass along w/
--provider-states-setup-url
? Once I correctly parse the consumer and state, what do I need to do in my controller to properly load the provider state? Thank you in advance for any and all assistance.
b
If you’re using pure ruby @Kellie Persson then you don’t need to make an endpoint.
There’s a Ruby DSL for defining them
k
The issue is we will be using pact-broker
b
I think you’re misunderstanding that the pact broker does.
😅 1
k
i have been able to verify already from the provider side but that’s just because i am testing it out locally
b
the pact broker is not involved with the replaying part of the interactions.
it’s just a service for sharing the pacts and the verification results.
the verification process takes place on your local machine or CI.
k
Okay. I am using pact-swift for my consumer tests (generate the pacts). I would like to be able to verify from the consumer end but for that I do need to access the test api for the provider state
b
there are two ways to do verification for ruby. If you’re ok using the version 2 of the specification (fewere features) then you can just use pure ruby as per the link I sent above.
If you want to use the verifier CLI (supports a higher version of the specification) then you will need to make an endpoint on your OWN api that can set up the provider states.
I would recommend doing one of the tutorials, as even though the language may be different, you’ll get the basic concpets worked out https://docs.pactflow.io/docs/tutorials
This is a pure ruby provider you can copy from for the provider states https://github.com/pact-foundation/pact-ruby/tree/master/example/animal-service
thankyou 1
awesome dance 1
k
Awesome. Thanks so much Beth. I have been able to verify using version 2 of the specification. Wanted to see if we would be able to support the higher version of the specification. Will go through the tutorial! Thanks again.
👍🏼 1