When you declare a request and response using the traditional Pact DSL, ("uponReceiving" and "willRespondWith") you're building a structure that has three purposes -
- it provides the concrete example request and response used in the tests
- it specifies the contents of the contract which...
- defines how to validate the the actual request/response against the expected request/response
The three different uses of this structure are hidden from you when using HTTP Pact because the mock service handles numbers 1 & 2 in the consumer tests, and the verification task handles number 3 for you in the provider tests. When using Pact in a non-HTTP scenario, there is no nice neat protocol layer to inject the code to do this for you, so you have to explicitly do each step.
The file expected_data_from_collector.rb
declares an object graph using the Pact DSL. This is going to be used to create the concrete example and the contract. This could be declared inline, but for easier maintenance, and to allow the contr