-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49988f0
commit 0cb1106
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
ENV["PACT_DO_NOT_TRACK"] = "true" | ||
|
||
require "pact/provider/rspec" | ||
require "webmock/rspec" | ||
require ::File.expand_path("../../config/environment", __dir__) | ||
|
||
Pact.configure do |config| | ||
config.reports_dir = "spec/reports/pacts" | ||
config.include WebMock::API | ||
config.include WebMock::Matchers | ||
end | ||
|
||
WebMock.allow_net_connect! | ||
|
||
def url_encode(str) | ||
ERB::Util.url_encode(str) | ||
end | ||
|
||
Pact.service_provider "Support API" do | ||
honours_pact_with "GDS API Adapters" do | ||
if ENV["PACT_URI"] | ||
pact_uri(ENV["PACT_URI"]) | ||
else | ||
base_url = "https://govuk-pact-broker-6991351eca05.herokuapp.com" | ||
path = "pacts/provider/#{url_encode(name)}/consumer/#{url_encode(consumer_name)}" | ||
version_modifier = "versions/#{url_encode(ENV.fetch('PACT_CONSUMER_VERSION', 'branch-main'))}" | ||
|
||
pact_uri("#{base_url}/#{path}/#{version_modifier}") | ||
end | ||
end | ||
end | ||
|
||
Pact.provider_states_for "GDS API Adapters" do | ||
provider_state "the parameters are valid" do | ||
set_up do | ||
params = { | ||
subject: "Feedback for app", | ||
tags: %w[app_name], | ||
user_agent: "Safari", | ||
description: "There is something wrong with this page.", | ||
} | ||
SupportTicket.new(params) | ||
end | ||
end | ||
|
||
provider_state "the required parameters are not provided" do | ||
set_up do | ||
params = { subject: "Feedback for app" } | ||
|
||
SupportTicket.new(params) | ||
end | ||
end | ||
end |