https://kotlinlang.org logo
s

snowe

01/29/2019, 6:50 AM
this looks like a spek question, but I promise it's not. Is there any way to extract this infix function out of the describe lambda and into a utility class or external location so that it's usable in other locations?
Copy code
describe("tiny object should") {
        infix fun Any.mapsTo(expected: String) {
            val testObject by memoized { this }

            it("test value") {
                pp(testObject)
                outContent shouldRenderLike expected
            }
        }

        context("render a single field") {
            TinyObject(1) mapsTo
                """
                TinyObject(
                  int = 1
                )
                """
        }
    }