Skip to content

Commit 6b04d70

Browse files
committed
feat: add HAL documentation for the relations that were missing documentation
Added tests to ensure that all new relations will be documented in the future. FIxes: pact-foundation#221
1 parent 50c003b commit 6b04d70

8 files changed

+65
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Latest pacts for provider with the specified tag
2+
3+
Allowed methods: `GET`
4+
5+
Given a provider name and a consumer version tag name, this resource returns the latest pact for each consumer that has the specified tag.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Latest pacts by provider
2+
3+
Allowed methods: `GET`
4+
5+
Given a provider name, this resource returns the latest pact for each consumer.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Latest pacticipant version with the specified tag
2+
3+
Allowed methods: `GET`
4+
5+
Given a pacticipant name and a pacticipant version tag name, this resource returns the latest pacticipant version with the specified tag. Note that the "latest" is determined by the creation date of the pacticipant version resource (or the semantic order if `order_versions_by_date` is false), not by the creation date of the tag.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Latest pacticipant version
2+
3+
Allowed methods: `GET`
4+
5+
Given a pacticipant name, this resource returns the latest pacticipant version according to the configured ordering scheme. Ordering will be by creation date of the version resource if `order_versions_by_date` is true, and will be by semantic order if `order_versions_by_date` is false.
6+
7+
Note that this resource represents a pacticipant (application) version, not a pact version.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Provider pacts
2+
3+
Allowed methods: `GET`
4+
5+
Given a pacticipant name and a consumer version tag, this resource returns all the pact versions for all consumers of this provider with the specified tag. The most common use of this resource is to find all the `production` pact versions for the mobile consumers of an API, so that backwards compatibility can be maintained.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Provider pacts
2+
3+
Allowed methods: `GET`
4+
5+
Given a pacticipant name, this resource returns all the pact versions for all consumers.

spec/lib/pact_broker/doc/controllers/app_spec.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require 'spec_helper'
21
require 'pact_broker/doc/controllers/app'
32

43
module PactBroker
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require 'pact_broker/doc/controllers/app'
2+
3+
RSpec.describe "the HAL docs for the index" do
4+
5+
let(:app) do
6+
Rack::Builder.new do
7+
map "/docs" do
8+
run PactBroker::Doc::Controllers::App
9+
end
10+
map "/" do
11+
run PactBroker::API
12+
end
13+
end
14+
end
15+
16+
let(:index_response) { get "/", {}, { 'HTTP_ACCEPT' => 'application/hal+json' } }
17+
let(:index_body) { JSON.parse(index_response.body) }
18+
19+
it "has a document for each relation" do
20+
relations_that_should_have_docs = index_body['_links'].keys - ['self', 'curies']
21+
relations_without_docs = {}
22+
23+
relations_that_should_have_docs.each do | relation |
24+
path = "/docs/#{relation.split(":", 2).last}"
25+
get path, {}, { 'HTTP_ACCEPT' => 'text/html' }
26+
if last_response.status != 200
27+
relations_without_docs[relation] = last_response.status
28+
end
29+
end
30+
31+
expect(relations_without_docs).to eq({})
32+
end
33+
end

0 commit comments

Comments
 (0)