pact-ruby icon indicating copy to clipboard operation
pact-ruby copied to clipboard

For HAL responses, should pact mock service url "localhost:1234" be displayed in generated documentation?

Open bethesque opened this issue 10 years ago • 1 comments

When using a Pact::Term.new(generate: "http://localhost:1234/some-path", matcher: %r{http://.*/some-path}) Or should it be replaced with example.org? Or the regexp?

{
  "status": 200,
  "headers": {
    "Content-Type": "application/hal+json"
  },
  "body": {
    "_links": {
      "some-resource": {
        "href": "http://localhost:1234/some-resource"
      }
    }
  }
}

or

{
  "status": 200,
  "headers": {
    "Content-Type": "application/hal+json"
  },
  "body": {
    "_links": {
      "some-resource": {
        "href": "http://example.org/some-resource"
      }
    }
  }
}

or

{
  "status": 200,
  "headers": {
    "Content-Type": "application/hal+json"
  },
  "body": {
    "_links": {
      "some-resource": {
        "href": "http:\/\/.*/some-resource"
      }
    }
  }
}

Thoughts: Regular expressions can be hard to read, example data is more meaningful, especially for something like a timestamp.

bethesque avatar May 01 '14 11:05 bethesque

https://github.com/realestate-com-au/pact/blob/master/lib/pact/doc/interaction_view_model.rb Replace all references to http://localhost:\d+ with "http://example.org".

bethesque avatar Dec 22 '14 23:12 bethesque

Believe option 1 has been chosen, use the generated value and validate that the matcher regex successfully applies to the generated

YOU54F avatar Aug 12 '24 14:08 YOU54F