Ashish Kumar Joy
07/11/2020, 5:52 PMinline fun <T> assertSoftly(assertions: () -> T): T
and the other with receiver object inline fun <T> T.assertSoftly(assertions: T.(T) -> Unit): T
currently any time a user uses assertSoftly .
assertSoftly {
1 shouldBe 1
}
It's always the second version with Spec class as receiver
even when user is not intended to use that version.
This is usually not a problem until user really want to use first version assertSoftly.
So i have this function.
fun <T> assertNextWith(publisher: Publisher<T>, first: (t: T) -> Unit, second: (t: T) -> Unit) {
StepVerifier.create(publisher)
.consumeNextWith(first)
.consumeNextWith(second)
.verifyComplete()
}
Its being used as shown in screenshot. Upto 4.0.5 version these tests were working fine, but on upgrading to 4.1.1 it start getting compilation error. As with earlier version of kotest it
was corresponding to the correctly to intented journey
but now with version upgrade it correspond to the spec class unintensionally.
I think we should change the signature of second version to
inline fun <T> assertSoftly(t: T, assertions: T.(T) -> Unit): T
Then its usage will be more explicit like this.
assertSoftly(person) {
name shouldBe "something"
}