Hi, I am working on implementing message pact test...
# pact-ruby
b
Hi, I am working on implementing message pact testing for a ruby on rails backend architecture. I have two rails apis communicating via AWS SNS. I have the consumer pact written and that seems to be working correctly - it generates a pact file with the expected message body. On the provider producer side I am running into a snag. I have been following the guides on this repo: https://github.com/AndrewJanuary/pact-ruby-demo and in this one: https://github.com/pact-foundation/pact-message-ruby. The problem is when I try to setup the provider test and call my code that generates the message, it can't find the class. My conclusion is that pact isn't instantiating my rails app. I can add requires to bring everything in but that gets very long and annoying. I was reading through the HTTP documentation here: https://docs.pact.io/implementation_guides/ruby/verifying_pacts#using-rake-pactverify and it says that "_Pact loads the app from config.ru by default. (it is recommended to let Pact use the config.ru if possible, so testing conditions are closest to runtime conditions)"_ Has anyone else run into this problem? should pact message load the app automatically? or does anyone have a repo that uses pact messaging on a rails app? My setup is essentially the same as this example here: https://github.com/AndrewJanuary/pact-ruby-demo/blob/main/spec/service_consumers/pact_helper.rb albeit I am on a rails app instead of a simple ruby app. Thanks you for your help!
For those interested, I did find a work around. Not sure if it is the best approach. but here is what I did:
# load the rails app before the test and then we can access our service and call it
Pact.set_up do Rack::Builder.parse_file(Pact.configuration.config_ru_path).first end
I do this before running the provider message pact verification. So the rails app is loaded into memory and available to call.