isAfterOrSameMomentAs function

Matcher isAfterOrSameMomentAs(
  1. DateTime date
)

Validates that a DateTime is after or the same moment as date.

This matcher has additional behavior when used in expectResponse, hasResponse, hasHeaders, hasBody: if the actual value is a String, it will attempted to be parsed into a DateTime first. If parsing fails, this matcher will fail.

    expectResponse(response, 200, headers: {"x-timestamp": isAfterOrSameMomentAs(DateTime())});

Implementation

Matcher isAfterOrSameMomentAs(DateTime date) {
  return predicate((DateTime d) => d.isAfter(date) || d == date,
      "after or same moment as ${date.toIso8601String()}");
}