feat(generators): Pass context and add ProviderState generator#209
feat(generators): Pass context and add ProviderState generator#209hhhonzik wants to merge 1 commit intopact-foundation:masterfrom
Conversation
|
Awesome! I'll be able to have a good look at it on Thursday (Australia time) as that's my OSS day. |
bethesque
left a comment
There was a problem hiding this comment.
Looks like it's on the right track.
| replay_interaction interaction, options[:request_customizer] | ||
| state_params = set_up_provider_states interaction.provider_states, options[:consumer] | ||
| interaction_context.state_params = state_params | ||
| replay_interaction interaction, options[:request_customizer], interaction_context |
There was a problem hiding this comment.
The interaction context is specifically a thing for the RSpec test - it is a hack that enables us to write multiple it blocks without actually re-running the request. Just pass in the state params directly.
| Pact.configuration.provider_state_set_up.call(provider_state.name, consumer, options.merge(params: provider_state.params)) | ||
| result = Pact.configuration.provider_state_set_up.call(provider_state.name, consumer, options.merge(params: provider_state.params)) | ||
| if result.is_a?(Hash) | ||
| state_params = state_params.merge(result) |
There was a problem hiding this comment.
Do we definitely want to merge them? There's potential for keys to be overwritten. Is that how pact-jvm is implemented?
There was a problem hiding this comment.
No, Pact-JVM just uses the values returned from the provider state callback
| end | ||
|
|
||
| def path | ||
| if expected_request.methods.include? :generators |
There was a problem hiding this comment.
expected_request.respond_to?(: generators) would be more idiomatic.
|
How's this going? I'd be very happy to get it in. |
We want to parse and use generators in the contract to change a request validation according to the spec.
Reasoning and approach is described in pact-provider-verifier: pact-foundation/pact-provider-verifier#53
Before this PR gets merged, I'd like to implement rest of generators specification and add test coverage.