header method
Asserts the response has a header with the given value.
Implementation
ResponseExpect header(String name, Object expected) {
final value = _response.headers.value(name);
if (value == null) {
throw ChaseTestFailure('Expected header "$name" but it was not present');
}
if (expected is Matcher) {
if (!expected.matches(value, {})) {
throw ChaseTestFailure(
'Header "$name" with value "$value" did not match expected',
);
}
} else if (value != expected.toString()) {
throw ChaseTestFailure(
'Expected header "$name" to be "$expected" but got "$value"',
);
}
return this;
}