pact-ruby
pact-ruby copied to clipboard
For HAL responses, should pact mock service url "localhost:1234" be displayed in generated documentation?
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.
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".
Believe option 1 has been chosen, use the generated value and validate that the matcher regex successfully applies to the generated