I have a question, and I think it mostly comes fro...
# pact-ruby
a
I have a question, and I think it mostly comes from me having a stronger Python background than Ruby. I have the following couple of files - but we parallelize our tests, and so I think that each spec file is trying to separately spin up pact servers, so I get errors that the address is already in use. Is there any accepted way to handle this?
I tried wrapping the set up in a
shared_context
, but the setup for the shared context gets run each time it’s included. I could just randomize the port every time, but that doesn’t seem like the right move
b
You’d really need to know what you were doing to get pact running parallel.
Each different process would need it’s own mock server
The mock server is stateful.
a
Gotcha - this makes sense
b
You could use this gem to find a free port https://rubygems.org/gems/find_a_port/versions/1.0.1
you’d also need to set the pact file write mode to “merge”
and wipe it before the test suite starts
if you dynamically set a port on the mock server, you can use
<your_service>.mock_service_base_url
to get the base URL to send the requests to.
🙏 1