Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

hhhonzik
Copy link

@hhhonzik hhhonzik commented Feb 23, 2020

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.

@bethesque
Copy link
Member

Awesome! I'll be able to have a good look at it on Thursday (Australia time) as that's my OSS day.

Copy link
Member

@bethesque bethesque left a 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
Copy link
Member

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)
Copy link
Member

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?

Copy link
Member

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
Copy link
Member

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.

@bethesque
Copy link
Member

How's this going? I'd be very happy to get it in.

@YOU54F
Copy link
Member

YOU54F commented Aug 6, 2024

superseded by #273

thanks @hhhonzik for kicking this off, i'll look at getting the rest of the work complete

@YOU54F YOU54F closed this Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants