feat([PoC]): Contract for sequence of messages.#21
feat([PoC]): Contract for sequence of messages.#21Mifrill wants to merge 1 commit intopact-foundation:masterfrom
Conversation
| message.events.map do |message_content| | ||
| Pact::Reification.from_term(message_content.contents) | ||
| end |
There was a problem hiding this comment.
📓 It will return an array even for a single record, so when we have only one message content, we show an array [content] in Contract, when we have multiple messages, we show an array of arrays [[Content]]
| hash = { :description => message.descriptions.join(';') } | ||
| hash[:providerStates] = provider_states | ||
| hash[:contents] = extract_contents | ||
| hash[:matchingRules] = extract_matching_rules |
There was a problem hiding this comment.
📝 matchingRules is still only for a single message
|
Thanks for the example pact-spec v4, which is implemented in the rust core, supports synchronous messages, which may return an array of responses It works well on the consumer side, but on the provider side, on the first response method is verfied. We would recommend migrating to rust core, and potentially proposing any changes there. Appreciate the contribution, will be closing this off however, as this gem will go into maintainence mode soon, as we have migrated pact-ruby to the rust core https://github.com/pact-foundation/pact-ruby/blob/master/documentation/README_V2.md |
📓 This PR is just a PoC on how to use Pact for a sequence of messages in a single test iteration. However, this approach is opposite to Consumer-driven Contract Testing (CDC), because is test should be as much simple as possible to test only one iteration (request-response) at a time.
When a Consumer expects a few messages in one test iteration current Pact is keeping only the last message in Contract, this modification makes Pact keeps all messages in Contract.
Contract:
{ "consumer": { "name": "Test Message Consumer" }, "provider": { "name": "Test Message Producer" }, "messages": [ { "description": "created;updated", "providerStates": [ { "name": "Class1", "params": { } }, { "name": "Class2", "params": { } } ], "contents": [ { "first_name": "John", "last_name": "Doe" }, { "hello": "world" } ], "matchingRules": { } } ], "metadata": { "pactSpecification": { "version": "2.0.0" } } }See demo: AndrewJanuary/pact-ruby-demo#1