Skip to content

Commit

Permalink
feat(verify): add request customizer for pact-provider-verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 6, 2018
1 parent fe2ebb1 commit 4ae0b58
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/pact/cli/run_pact_verification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/pact/provider/pact_spec_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/pact/provider/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/pact/provider/test_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4ae0b58

Please sign in to comment.