Hello! I have a question regarding Pact and contra...
# pact-ruby
p
Hello! I have a question regarding Pact and contract/functional testing! If I had a consumer client such as the one below, I think writing a test for the sign_up method is pretty straightforward. It it similar to the zoo-app example and makes sense to me. But how would I approach a method such as sign_in, where there is a series of requests stemming from the same ConsumerExample client method. This would result in a sequence of requests, and I'm just not sure what to make of this (how to test ConsumerExample.sign_in). Should I be testing at the http_client level? Is the Consumer example containing business logic a red flag? Is there a creative/best practice? I can't seem to find anything after googling around for a while - hoping I can get a little more intuition here, or maybe a link to some relevant examples/documentation. Thanks! cc @Andy Jenness
Would I just break out these requests as separate tests, trigger then via the http client, and then manipulate the provider states such that each can be ran independently?
t
In a Pact test, each interaction is independent. So the general answer to “how do I handle an operation with multiple requests” is to break out the requests in to separate interactions controlled by provider state
🙌 1
However, for login, this usually isn’t practical, because usually your login code is handled by a library that does the oauth dance for you.
if you’re hand rolling the oauth dance, or have some other custom login system, then you might want to do pact tests for each request.
if not, personally I would just leave it out of the contract
p
Thanks Timothy - Might have some follow up but this makes sense. Appreciate the response.