pact-foundation / pact-ruby

Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://pact.io
MIT License
2.17k stars 216 forks source link

feat(generators): Add ProviderState generator & others #273

Closed slt closed 3 months ago

slt commented 2 years ago

This is required to support using provider state generators in pact-provider-verifier https://github.com/pact-foundation/pact-provider-verifier/pull/85

Requires https://github.com/pact-foundation/pact-support/pull/97

My work is based on @hhhonzik's earlier pull requests

https://github.com/pact-foundation/pact-provider-verifier/pull/53 https://github.com/pact-foundation/pact-ruby/pull/209

I have never written Ruby before so please forgive if it's not very idiomatic - happy to action any feedback given.

bethesque commented 2 years ago

Sorry for the slow reply. Thank you so much for this! @uglyog can you have a look at this and see if it's inline with how the other implementations work please?

slt commented 2 years ago

It requires https://github.com/pact-foundation/pact-support/pull/97 in order to pass the tests

I have been using this as part of my own build of pact-provider-verifier successfully for the last month

I would welcome any feedback and am happy to action any changes

rholshausen commented 2 years ago

Looks good to me

slt commented 2 years ago

If we could please get https://github.com/pact-foundation/pact-support/pull/97 (which is only minor) merged over in that project, then this pull request should start passing tests here🤞

bethesque commented 2 years ago

Have released pact-support.

slt commented 2 years ago

Thank you! I've updated the pact.gemspec to use the new pact-support version

slt commented 2 years ago

Looks like it has passed 🎆 🥳

bethesque commented 2 years ago

@slt I'm sorry it's taken so long to get this in. I don't have a lot of extra bandwidth at the moment. I really appreciate your contribution!

Before we merge this in, we need to work out how this is going to be supported. Are you willing to be available to answer community questions about this and fix any bugs, because I won't be able to help with this. If so, it would be great if you could be in the #pact-ruby channel in our slack workspace if you aren't already. It also needs to be documented. Would you be happy to pick that up?

Again, really really appreciate your work on this!

slt commented 2 years ago

Hi @bethesque

I am more than happy to do the documentation and answer any questions or do bug fixes in the short term, but this is the first time I've written anything in ruby so I'm not really too knowledgeable or invested in ruby long term, unfortunately.

I have mostly written this pull request (selfishly) to unblock myself and to get the feature into the standalone pact-provider-verifier via https://github.com/pact-foundation/pact-provider-verifier/pull/85 for use in my organisation's Go and PHP projects, where I am pushing for us to adopt Pact.

Also, I have not really been focused on the use case of those using this library directly in their ruby projects, I think there is additional work to be done for it to make total sense there.

From the matrix on https://docs.pact.io/roadmap/feature_support and from my understanding

This pull request should tick the box for:

But to be able to generate contracts that use any of these features in pact-ruby you also need:

I'm going for a long break over December, so happy to hold off and revisit in the new year if that works better. I've been idling in #pact-ruby but have said hello today :) Thank you for taking a look

slt commented 2 years ago

On a side note, I just found pact-rust's pact_verifier_cli. Am I better off using that instead of trying to improve pact-provider-verifier?

I am not really tied to a language, I am just looking for something I can run independently from a docker container

Does that already do what I'm trying to achieve here?

bethesque commented 2 years ago

Am I better off using that instead of trying to improve pact-provider-verifier?

Yes!

Sorry, I thought you were doing this for the Ruby native implementation. I would have let you know about the rust verifier if I'd realised!

YOU54F commented 1 year ago

Thanks @slt for your work on this, appreciate that you mentioned you are not a Ruby developer and so providing support for it would be tricky.

I will in the meantime invite anyone who wants to review to add comments or support for this it would be much appreciated, and if not, we will endeavour to get this out and documented when we can :)

YOU54F commented 3 months ago

closing in favour of #320, thanks Steve