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.16k stars 214 forks source link

File_upload/support for multi-part media upload #175

Open NataliaAru opened 5 years ago

NataliaAru commented 5 years ago

I am trying to write a pact test in Ruby, where consumer makes a post call with payload{ multipart: true, file: fileObject, name: "name" } where file is some kind of media file. please, make support for this feature

bethesque commented 5 years ago

Are you interested in working on this with me @NataliaAru?

NataliaAru commented 5 years ago

@bethesque I don't have much experience, but i would love to contribute if I can!

bethesque commented 5 years ago

Ok, I've released version 1.33.0 with support for multipart/form matching. Here's an example of how to do the matching:

https://github.com/pact-foundation/pact-ruby/blob/master/spec/features/consumer_with_file_upload_spec.rb

As you can see, the interface is a bit clunky compared to the Groovy

If you're interested in contributing, you could have a go at making a nicer way of creating the expected upload body and headers?

file_upload_service
       .upon_receiving("a request to upload a file")
       .with(method: :post, path: '/files')
       .and_file('file', 'text.txt', 'text/plain', File.read(file_to_upload))
        will_respond_with(status: 200)
bethesque commented 5 years ago

This is the class for the fluent API https://github.com/pact-foundation/pact-ruby/blob/master/lib/pact/consumer/interaction_builder.rb

NataliaAru commented 5 years ago

ah, I will test this against our project and try to do the interface!

bethesque commented 5 years ago

Closing due to inactivity, but please reopen if needed.