How do I match an amount of collection elements th...
# strikt
d
How do I match an amount of collection elements that match the predicate?
Copy code
fun <T : Iterable<E>, E> Assertion.Builder<T>.only(expected: Int, predicate: Assertion.Builder<E>.() -> Unit): Assertion.Builder<T> =
		compose("only $expected elements match:") { subject ->
			subject.forEach { element ->
				get("%s") { element }.apply(predicate)
			}
		} then {
                        // I need the amount of assertions that passed here... anyPassed doesn't help here...
			if (anyPassed) pass() else fail()
		}
@robfletcher