Sha256: 1c2bb4bb69b386a686d595bc7e4c2d6fb1e663b7c716821f297494e8466b85ff

Contents?: true

Size: 1.24 KB

Versions: 12

Compression:

Stored size: 1.24 KB

Contents

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) }
  let(:docs_missing_string) { "No documentation exists"}

  it "returns a known message when the documentation doesn't exist" do
    get "/docs/does-not-exist?context=index", {}, { "HTTP_ACCEPT" => "text/html" }
    expect(last_response.body).to include docs_missing_string
  end

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

    relations_that_should_have_docs.each do | relation |
      path = "/docs/#{relation.split(":", 2).last}?context=index"
      get path, {}, { "HTTP_ACCEPT" => "text/html" }
      if last_response.body.include?(docs_missing_string)
        relations_without_docs[relation] = last_response.status
      end
    end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pact_broker-2.89.1 spec/lib/pact_broker/doc/coverage_spec.rb
pact_broker-2.89.0 spec/lib/pact_broker/doc/coverage_spec.rb
pact_broker-2.88.0 spec/lib/pact_broker/doc/coverage_spec.rb
pact_broker-2.87.0 spec/lib/pact_broker/doc/coverage_spec.rb
pact_broker-2.86.0 spec/lib/pact_broker/doc/coverage_spec.rb
pact_broker-2.85.1 spec/lib/pact_broker/doc/coverage_spec.rb
pact_broker-2.85.0 spec/lib/pact_broker/doc/coverage_spec.rb
pact_broker-2.84.0 spec/lib/pact_broker/doc/coverage_spec.rb
pact_broker-2.83.0 spec/lib/pact_broker/doc/coverage_spec.rb
pact_broker-2.82.0 spec/lib/pact_broker/doc/coverage_spec.rb
pact_broker-2.81.0 spec/lib/pact_broker/doc/coverage_spec.rb
pact_broker-2.80.0 spec/lib/pact_broker/doc/coverage_spec.rb