diff --git a/lib/pact/cli/run_pact_verification.rb b/lib/pact/cli/run_pact_verification.rb index 97d32492..203f11ef 100644 --- a/lib/pact/cli/run_pact_verification.rb +++ b/lib/pact/cli/run_pact_verification.rb @@ -72,7 +72,8 @@ def pact_spec_options criteria: SpecCriteria.call(options), format: options[:format], out: options[:out], - ignore_failures: options[:ignore_failures] + ignore_failures: options[:ignore_failures], + request_customizer: options[:request_customizer] } end end diff --git a/lib/pact/provider/pact_spec_runner.rb b/lib/pact/provider/pact_spec_runner.rb index d1dbc4ec..7db51560 100644 --- a/lib/pact/provider/pact_spec_runner.rb +++ b/lib/pact/provider/pact_spec_runner.rb @@ -120,7 +120,8 @@ def initialize_specs pact_sources.each do | pact_source | options = { criteria: @options[:criteria], - ignore_failures: @options[:ignore_failures] + ignore_failures: @options[:ignore_failures], + request_customizer: @options[:request_customizer] } honour_pactfile pact_source.uri, ordered_pact_json(pact_source.pact_json), options end diff --git a/lib/pact/provider/rspec.rb b/lib/pact/provider/rspec.rb index d9883bef..e6e8507a 100644 --- a/lib/pact/provider/rspec.rb +++ b/lib/pact/provider/rspec.rb @@ -85,7 +85,7 @@ def describe_interaction interaction, options interaction_context.run_once :before do Pact.configuration.logger.info "Running example '#{Pact::RSpec.full_description(example)}'" set_up_provider_state interaction.provider_state, options[:consumer] - replay_interaction interaction + replay_interaction interaction, options[:request_customizer] interaction_context.last_response = last_response end end diff --git a/lib/pact/provider/test_methods.rb b/lib/pact/provider/test_methods.rb index 76486685..c46b6100 100644 --- a/lib/pact/provider/test_methods.rb +++ b/lib/pact/provider/test_methods.rb @@ -14,8 +14,9 @@ module TestMethods include Pact::Logging include Rack::Test::Methods - def replay_interaction interaction + def replay_interaction interaction, request_customizer = nil request = Request::Replayable.new(interaction.request) + request = request_customizer.call(request, interaction) if request_customizer args = [request.path, request.body, request.headers] logger.info "Sending #{request.method.upcase} request to path: \"#{request.path}\" with headers: #{request.headers}, see debug logs for body"