DiUS / pact-consumer-js-dsl

*DEPRECATED* A Javascript DSL for creating pacts, superceded by Pact JS
https://github.com/pact-foundation/pact-js
Other
56 stars 26 forks source link

Fix MockServer base url bug #14

Closed BenSayers closed 9 years ago

BenSayers commented 9 years ago

I thought about introducing an immutable internal object to represent the current state of MockService but decided that was too complex, and instead opted for a simple fix. Tests are updated and green.

I still think this object needs some work however, as it continues to have unexpected behaviour due to shared state. For example:

var mock1 = Pact.mockService({consumerName: 'client', port: 1234, providerName: 'server', pactDir: 'spec/pacts'});
mock1.write(); //makes request to localhost:1234
var mock2 = Pact.mockService({consumerName: 'client', port: 4321, providerName: 'server', pactDir: 'spec/pacts'});
mock2.write(); //makes request to localhost:4321
mock1.write(); //makes request to localhost:4321 - this is unexpected
bethesque commented 9 years ago

I don't get why mock1 points to 4321. The mockService method should create a completely new instance. I'll merge the PR, and have a look at it.

bethesque commented 9 years ago

Yeah, that's not right at all. I did not read the refactor PR properly, and let it though. I will fix that now.

bethesque commented 9 years ago

Please grab the latest copy, I have fixed the problem.