Sha256: 97cd843384d19f2c9d94a277ec402b2b2e5f8a6023253d0271922501d781bd36
Contents?: true
Size: 1.81 KB
Versions: 1
Compression:
Stored size: 1.81 KB
Contents
require 'rake/tasklib' require 'pact/producer/pact_spec_runner' =begin To create a rake pact:verify:<something> task Pact::VerificationTask.new(:head) do | pact | pact.uri 'http://master.cd.vpc.realestate.com.au/browse/BIQ-MAS/latestSuccessful/artifact/JOB2/Pacts/mas-contract_transaction_service.json', support_file: './spec/consumers/pact_helper' pact.uri 'http://master.cd.vpc.realestate.com.au/browse/BIQ-IMAGINARY-CONSUMER/latestSuccessful/artifact/JOB2/Pacts/imaginary_consumer-contract_transaction_service.json', support_file: './spec/consumers/pact_helper' end The pact.uri may be a local file system path or a remote URL. The support_file should include code that makes your rack app available for the rack testing framework. Eg. Pact.configure do | config | config.producer do name "My Producer" app { TestApp.new } end end It should also load all your app's dependencies (eg by calling out to spec_helper) =end module Pact class VerificationTask < ::Rake::TaskLib attr_reader :pact_spec_config def initialize(name) @pact_spec_config = [] yield self namespace :pact do desc "Verify producer against the consumer pacts for #{name}" task "verify:#{name}" do exit_status = Producer::PactSpecRunner.run(pact_spec_config) fail failure_message if exit_status != 0 end def failure_message "\n* * * * * * * * * * * * * * * * * * *\n" + "Producer did not honour pact file.\nSee\n * #{Pact.configuration.log_path}\n * #{Pact.configuration.tmp_dir}\nfor logs and pact files." + "\n* * * * * * * * * * * * * * * * * * *\n\n" end end end def uri(uri, options) @pact_spec_config << {uri: uri, support_file: options[:support_file], consumer: options[:consumer]} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pact-0.1.28 | lib/pact/verification_task.rb |