Use Pact regex for checking header output on Organisations API
Use Pact regex for checking header output on Organisations API

The header value changes according to the value the host value
provided by the client. In our case, it's `localhost:3002`, as we
need to differentiate between other APIs running on localhost, as
the following code locks up the port for use:

```
Pact.service_consumer "GDS API Adapters" do
  has_pact_with "Collections Organisation API" do
    mock_service :organisation_api do
      port ORGANISATION_API_PORT
    end
  end
end
```

However, rather than keeping this port number in sync on the
Collections repo itself, we're just leaving the default `example.org`
header. This means that the pagination header is different; our
GDS API Adapters assertion until now had expected exactly the
localhost string, where it would now be encountering an example.org
string.

We could have wrapped this in a `Pact.like`, rather than `Pact.term`,
but all this does is check that the return value is a string, so
we needed something more specific. This feature isn't well documented;
I had to dig into the code to find it:
https://github.com/pact-foundation/pact-support/blob/master/lib/pact/helpers.rb

We now check that the header looks as it should, without specifying
what the host should be.

We're now in a slightly disingenuous situation where we're mocking
the return value in organisations_api_test using RSpec `let`, i.e.
writing a regex for a string that we're also controlling in the
same file. However, the test does work - I tried changing the
return value to an empty string in Collections and found that the
regex was failing:
https://github.com/alphagov/collections/blob/d139e918a6ea79cd5fb43bbcd7af454fbd136d9b/app/presenters/link_header_presenter.rb#L11

So we can be reasonably confident that this new regex is actually
validating that the header contains what we think it should.

alphagov/gds-api-adapters