I programmatically set the ENV value to each of the pact description I
want to verify before calling the verification task. So
# First pact to verify
ENV['PACT_DESCRIPTION'] = 'description_of_my_first_pact
Rake::Task["pact:verify:#{service}"].execute
# Second pact to verify
ENV['PACT_DESCRIPTION'] = 'description_of_my_second_pact
Rake::Task["pact:verify:#{service}"].execute
etc.
I'm relying on
https://github.com/realestate-com-au/pact/wiki/Verifying-pacts,
which suggested using
$ rake pact:verify PACT_DESCRIPTION="a request for something"
PACT_PROVIDER_STATE="something exists"
My whole Rake task (which I'm happy to accept is a hack, I haven't
figured out a better way to do it)
desc('Run the provider integration tests, in the specified order, ')
task(:provider_verify_ordered) do
Rake::TestTask.new(:dummy_name) do
require 'pact/provider/proxy/tasks'
Pact::ProxyVerificationTask.new :userapi_service do | task |
task.pact_url
'./spec/pacts/userapi_service_consumer-userapi_service_provider.json'
task.provider_base_url '
https://userapi.****.com/'
end
Pact::ProxyVerificationTask.new :otherapi_service do | task |
task.pact_url
'./spec/pacts/otherapi_service_consumer-otherapi_service_provider.json'
task.provider_base_url '
https://otherapi.*****.com'
end
pacts_to_verify= [['registration
success','user'],['get_offer','other'],['issue offer','offer'],
['payment','user'],['get extra offers','other']]
pacts_to_verify.each{ |pact,s|
begin
service = (s == 'user' ? 'userapi_service' : 'otherapi_service')
puts "Checking Pact #{pact} on #{service}"
ENV['PACT_DESCRIPTION']=pact
Rake::Task["pact:verify:#{service}"].execute
rescue Exception => e
puts e.inspect
puts "Checking Pact #{pact} failed\n\n"
end
}
# Code that greps through the files to count how many pacts there are
to make sure I didn't miss any.
André