-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1273 from alphagov/add-support-api-pact-tests
Add Pact tests for Support API
- Loading branch information
Showing
6 changed files
with
109 additions
and
9 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
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
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
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,67 @@ | ||
require "test_helper" | ||
require "gds_api/support_api" | ||
|
||
describe "GdsApi::SupportApi pact tests" do | ||
include PactTest | ||
|
||
describe "#raise_support_ticket" do | ||
let(:api_client) { GdsApi::SupportApi.new(support_api_host) } | ||
|
||
it "responds with a 201 Success if the parameters provided are valid" do | ||
support_api | ||
.given("the parameters are valid") | ||
.upon_receiving("a raise ticket request") | ||
.with( | ||
method: :post, | ||
path: "/support-tickets", | ||
headers: GdsApi::JsonClient.default_request_with_json_body_headers, | ||
body: { | ||
subject: "Feedback for app", | ||
tags: %w[app_name], | ||
user_agent: "Safari", | ||
description: "There is something wrong with this page.", | ||
}, | ||
) | ||
.will_respond_with( | ||
status: 201, | ||
body: { | ||
status: "success", | ||
}, | ||
headers: { | ||
"Content-Type" => "application/json; charset=utf-8", | ||
}, | ||
) | ||
|
||
api_client.raise_support_ticket( | ||
subject: "Feedback for app", | ||
tags: %w[app_name], | ||
user_agent: "Safari", | ||
description: "There is something wrong with this page.", | ||
) | ||
end | ||
|
||
it "responds with 422 Error when required parameters are not provided" do | ||
support_api | ||
.given("the required parameters are not provided") | ||
.upon_receiving("a raise ticket request") | ||
.with( | ||
method: :post, | ||
path: "/support-tickets", | ||
headers: GdsApi::JsonClient.default_request_with_json_body_headers, | ||
body: { | ||
subject: "Ticket without body", | ||
}, | ||
) | ||
.will_respond_with( | ||
status: 422, | ||
body: { | ||
status: "error", | ||
}, | ||
) | ||
|
||
assert_raises GdsApi::HTTPUnprocessableEntity do | ||
api_client.raise_support_ticket(subject: "Ticket without body") | ||
end | ||
end | ||
end | ||
end |
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
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