asIterable

infix fun <E, T : Sequence<E>> Expect<T>.asIterable(o: o): Expect<Iterable<E>>(source)

Turns Expect<E, T : Sequence<E>> into Expect<Iterable<E>>.

The transformation as such is not reflected in reporting. Use feature { f(it::asIterable) } if you want to show the transformation in reporting.

Return

The newly created Expect for the transformed subject.

Samples

val sequence = sequenceOf(1, 2, 3)
expect(sequence) asIterable o toContain o inGiven order and only the values(1, 2, 3)
//                  |                       | order specifier
//                  |  subject is now of type Iterable<Int>

fails {
    expect(sequenceOf(1, 2, 3)) asIterable o toContain 4
    //                                      | subject is now of type Iterable<Int>
}

infix fun <E, T : Sequence<E>> Expect<T>.asIterable(assertionCreator: Expect<Iterable<E>>.() -> Unit): Expect<T>(source)

Expects that the subject of this expectation holds all assertions the given assertionCreator creates for the subject as Iterable.

The transformation as such is not reflected in reporting. Use feature of({ f(it::asIterable) }, assertionCreator) if you want to show the transformation in reporting.

Return

an Expect for the subject of this expectation.

Samples

expect(sequenceOf(1, 2, 3))
    .asIterable { //subject within this expectation-group is of type Iterable<Int>
        it toContain 1
        it toContain 2
        it toContain 3
    } // subject is back to Sequence<Int>

fails {
    expect(sequenceOf(1, 2, 3))
        .asIterable { //subject within this expectation-group is of type Iterable<Int>

            it toContain 4
        } //subject here is back to type Sequence<Int>
}