-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(generators): Pass context and add ProviderState generator #209
Conversation
Awesome! I'll be able to have a good look at it on Thursday (Australia time) as that's my OSS day. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, Pact-JVM just uses the values returned from the provider state callback
end | ||
|
||
def method | ||
expected_request.method | ||
end | ||
|
||
def path | ||
if expected_request.methods.include? :generators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.