Skip to content

Commit

Permalink
feat: add HAL documentation for the relations that were missing docum…
Browse files Browse the repository at this point in the history
…entation

Added tests to ensure that all new relations will be documented in the future.

FIxes: #221
  • Loading branch information
bethesque committed Jul 7, 2018
1 parent 50c003b commit 6b04d70
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Latest pacts for provider with the specified tag

Allowed methods: `GET`

Given a provider name and a consumer version tag name, this resource returns the latest pact for each consumer that has the specified tag.
5 changes: 5 additions & 0 deletions lib/pact_broker/doc/views/latest-provider-pacts.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Latest pacts by provider

Allowed methods: `GET`

Given a provider name, this resource returns the latest pact for each consumer.
5 changes: 5 additions & 0 deletions lib/pact_broker/doc/views/latest-tagged-version.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Latest pacticipant version with the specified tag

Allowed methods: `GET`

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.
7 changes: 7 additions & 0 deletions lib/pact_broker/doc/views/latest-version.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Latest pacticipant version

Allowed methods: `GET`

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.

Note that this resource represents a pacticipant (application) version, not a pact version.
5 changes: 5 additions & 0 deletions lib/pact_broker/doc/views/provider-pacts-with-tag.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Provider pacts

Allowed methods: `GET`

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.
5 changes: 5 additions & 0 deletions lib/pact_broker/doc/views/provider-pacts.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Provider pacts

Allowed methods: `GET`

Given a pacticipant name, this resource returns all the pact versions for all consumers.
1 change: 0 additions & 1 deletion spec/lib/pact_broker/doc/controllers/app_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'spec_helper'
require 'pact_broker/doc/controllers/app'

module PactBroker
Expand Down
33 changes: 33 additions & 0 deletions spec/lib/pact_broker/doc/coverage_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'pact_broker/doc/controllers/app'

RSpec.describe "the HAL docs for the index" do

let(:app) do
Rack::Builder.new do
map "/docs" do
run PactBroker::Doc::Controllers::App
end
map "/" do
run PactBroker::API
end
end
end

let(:index_response) { get "/", {}, { 'HTTP_ACCEPT' => 'application/hal+json' } }
let(:index_body) { JSON.parse(index_response.body) }

it "has a document for each relation" do
relations_that_should_have_docs = index_body['_links'].keys - ['self', 'curies']
relations_without_docs = {}

relations_that_should_have_docs.each do | relation |
path = "/docs/#{relation.split(":", 2).last}"
get path, {}, { 'HTTP_ACCEPT' => 'text/html' }
if last_response.status != 200
relations_without_docs[relation] = last_response.status
end
end

expect(relations_without_docs).to eq({})
end
end

0 comments on commit 6b04d70

Please sign in to comment.