org.jetbrains.spek.subject.Shared.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spek-subject-extension Show documentation
Show all versions of spek-subject-extension Show documentation
A Specification Framework for the JVM
package org.jetbrains.spek.subject
import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.Spec
import org.jetbrains.spek.api.include
import org.jetbrains.spek.api.lifecycle.CachingMode
import org.jetbrains.spek.api.lifecycle.LifecycleAware
import org.jetbrains.spek.meta.Experimental
import org.jetbrains.spek.subject.dsl.SubjectDsl
import org.jetbrains.spek.subject.dsl.SubjectProviderDsl
import kotlin.reflect.KProperty
@Experimental
infix fun SubjectDsl.itBehavesLike(spec: SubjectSpek) {
include(Spek.wrap {
val value: SubjectProviderDsl = object: SubjectProviderDsl, Spec by this {
val adapter = object: LifecycleAware {
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
return this()
}
override fun invoke(): T {
return [email protected]().invoke()
}
}
override fun subject() = adapter
override fun subject(mode: CachingMode, factory: () -> T) = adapter
override val subject: T
get() = adapter()
}
spec.spec(value)
})
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy