isBefore function

Matcher isBefore(
  1. DateTime date
)

Validates that a DateTime is before 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": isBefore(DateTime())});

Implementation

Matcher isBefore(DateTime date) {
  return predicate(
      (DateTime d) => d.isBefore(date), "before ${date.toIso8601String()}");
}