expekt
expekt copied to clipboard
ExpectAny should be extendable
Subject and words of ExpectAny
should be accessible publicly so that we can write extension functions for own assertions on the subject with own words being logged.
The following for example checks that two collections are equal while ignoring the order of the elements:
fun <Element> ExpectCollection<Element>.equalIgnoringOrder(expected: Collection<Element>) =
apply {
satisfy { subject ->
val subjectList = subject.toList()
val expectedList = expected.toList()
subjectList.size == expectedList.size
&& subjectList.all(expectedList::contains)
&& expectedList.all(subjectList::contains)
}
}
Due to lack of access to subject
the function satisfy
must be used to access the subject.
Due to lack of access to words
a failure would log satisfy predicate
instead of something more helpful like equalIgnoringOrder $expected
.