has<R> method
Extracts a property of the value for further expectations.
Sets up a clause that the value "has name
that:" followed by any
expectations applied to the returned Subject.
Implementation
@meta.useResult
Subject<R> has<R>(R Function(T) extract, String name) {
return context.nest(() => ['has $name'], (value) {
try {
return Extracted.value(extract(value));
} catch (e, st) {
return Extracted.rejection(which: [
...prefixFirst('threw while trying to read $name: ', literal(e)),
...const LineSplitter().convert(st.toString())
]);
}
});
}