sr
01/12/2024, 12:21 PMcargo build. I have also installed the rubygem ffi in the provider project.Matt (pactflow.io / pact-js / pact-go)
sr
01/12/2024, 9:26 PMMatt (pactflow.io / pact-js / pact-go)
sr
01/12/2024, 9:28 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
sr
01/15/2024, 11:28 AMpact_helper.rb should look when using the FFI implementation, and and example of provider_states alsoYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Ok thanks. I was under the impression I needed to use the rust library, compile it and reference it in Ruby using the ffi gem. But that’s all guesswork at this point 👍 hopefully you find somethingThe Pact-Reference provides shared libraries in the releases section under pact_ffi. These are shared libraries which you can load with the
ffi gem.
You need to map the methods exposed by the FFI in C (pre compiled from Rust) in Ruby, and then you can use them as though they are somewhat native to Ruby. Feel free to let us know how you get on, and happy to help answer any questions.
PS. Happy for anyone to fork and hack on that repo, or start afresh 🙂 not precious about itYousaf Nabi (pactflow.io)
sr
01/15/2024, 8:44 PM# In spec/service_consumers/pact_helper.rb
require 'pact/provider/rspec'
Pact.service_provider "Animal Service" do
honours_pact_with 'Zoo App' do
# This example points to a local file, however, on a real project with a continuous
# integration box, you would use a [Pact Broker](<https://github.com/pact-foundation/pact_broker|https://github.com/pact-foundation/pact_broker>) or publish your pacts as artifacts,
# and point the pact_uri to the pact published by the last successful build.
pact_uri '../zoo-app/spec/pacts/zoo_app-animal_service.json'
end
endYousaf Nabi (pactflow.io)
sr
01/18/2024, 4:01 PMPact.service_provider "Provider-app" do
publish_verification_results true
honours_pacts_from_pact_broker do
pact_broker_base_url "<http://localhost:9292/>"
app_version "1.0.0"
app_version_branch "main"
app_version_tags ["foo", "bar"]
end
endYousaf Nabi (pactflow.io)
none of it is abstracted away like the ruby gem is?correct., pact-ruby provides a nice dsl to the user as shown in your example. pact-ruby-ffi gem has the glue code which allows the individual methods to be called in the rust backend core. They haven’t been integrated together yet You can either 1. utilise pact-ruby-ffi in its raw form, and call the individual methods to setup your verifier, a. https://github.com/YOU54F/pact-ruby-ffi/blob/c29c7bce58e8c87c40a894f379dfac12868e2375/spec/pactffi_verifier_spec.rb#L43-L47 2. integrate pact-ruby with pact-ruby-ffi, such that behind the scenes to the user, the input parameters are mapped to the relevant ffi functions. This is the ultimate aim, I would imagine, and the path of least resistance for end users of the pact-ruby library.
I have been reviewing the example above and I am struggling to understand what is happening here. So you are having to manually start the mock server in codeIn the code above, 1. I am using fake provider application, which I am starting before the test, so that my Pact verifier, has a real endpoint to call. a. https://github.com/YOU54F/pact-ruby-ffi/blob/c29c7bce58e8c87c40a894f379dfac12868e2375/spec/pactffi_verifier_spec.rb#L9-L35 2. I instantiate the pact verifier a. https://github.com/YOU54F/pact-ruby-ffi/blob/c29c7bce58e8c87c40a894f379dfac12868e2375/spec/pactffi_verifier_spec.rb#L36 3. I pass various options to the verifier. In this case, the provider info (name, base path, port) and the Pact source ( a file in this case) a. https://github.com/YOU54F/pact-ruby-ffi/blob/c29c7bce58e8c87c40a894f379dfac12868e2375/spec/pactffi_verifier_spec.rb#L43-L45 4. I then call the verifier, which will issue requests to my provider, and return the results a. https://github.com/YOU54F/pact-ruby-ffi/blob/c29c7bce58e8c87c40a894f379dfac12868e2375/spec/pactffi_verifier_spec.rb#L46
sr
01/18/2024, 4:13 PMYousaf Nabi (pactflow.io)
Matt (pactflow.io / pact-js / pact-go)
I have been reviewing the example above and I am struggling to understand what is happening here. So you are having to manually start the mock server in code, none of it is abstracted away like the ruby gem is?
If you simply want to pull down pact file from a broker, run them and publish the results can that not be achieved simply as before?exactly. To elaborate, the rust core is a low level C interface that provides all of the capabilities for any language to integrate and use. e.g. Pact JS has a high level DSL for users, but under the hood it maps to all of these functions.