Use local delegated properties with subjects
Opened this issue · 0 comments
raniejade commented
So Jetbrains just announced Kotlin's Post 1.0 Roadmap and one of the planned features is local delegated properties
. This can be very useful with subjects!
describe(Foo::class) {
val foo by subject() // using no-arg constructor
}
// or
describe(Foo::class) {
val foo by subject {
return@subject Foo(1, 2)
}
}
This is very similar to RSpec's memoized helpers, heck we can even support let
.
describe("foo") {
var count = 0
val something by let {
return@let ++count
}
it("it should be 1") {
assert(something == 1)
}
it("it should be 2") {
assert(something == 2)
}
}