diff --git a/consumer/spec/bar_spec.rb b/consumer/spec/bar_spec.rb index 8112f6b..c6e8608 100644 --- a/consumer/spec/bar_spec.rb +++ b/consumer/spec/bar_spec.rb @@ -15,7 +15,9 @@ headers: { 'Content-Type' => 'application/json' }, body: { company: Pact.like("My big company"), - factories: Pact.each_like(location: "Sydney", capacity: 5) + factories: Pact.each_like(location: "Sydney", capacity: 5), + received_at: Pact.term(generate: "2017-10-23T11:50:12Z", matcher: /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)$/), + received_at_matcher: Pact.like_datetime("2017-10-23T11:50:12Z") } }) diff --git a/consumer/spec/pacts/foo-bar.json b/consumer/spec/pacts/foo-bar.json index ec7f9a5..fe7e8a9 100644 --- a/consumer/spec/pacts/foo-bar.json +++ b/consumer/spec/pacts/foo-bar.json @@ -27,7 +27,9 @@ "location": "Sydney", "capacity": 5 } - ] + ], + "received_at": "2017-10-23T11:50:12Z", + "received_at_matcher": "2017-10-23T11:50:12Z" }, "matchingRules": { "$.body.company": { @@ -38,6 +40,14 @@ }, "$.body.factories[*].*": { "match": "type" + }, + "$.body.received_at": { + "match": "regex", + "regex": "^\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z)$" + }, + "$.body.received_at_matcher": { + "match": "regex", + "regex": "^\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z)$" } } } diff --git a/provider/bar_app.rb b/provider/bar_app.rb index 83e2083..1112f42 100644 --- a/provider/bar_app.rb +++ b/provider/bar_app.rb @@ -13,8 +13,11 @@ def call env "location": "Sydney", "geographicCoords": "-0.145,1.4445", "capacity": 5, - } - ] + }, + ], + "received_at": "2017-10-25T01:26:00Z", + "received_at_matcher": "2017-10-25T01:26:00Z" + }.to_json [status, headers, [body]] end