iamsteveholmes
11/05/2015, 6:53 PMiamsteveholmes
11/05/2015, 6:54 PMhastebrot
11/05/2015, 6:54 PMassertThat(value, matcher
) a lot and find it a bit cumbersome to import all these matchers. Also auto-complete is not so nice with Hamcrest.iamsteveholmes
11/05/2015, 6:54 PMiamsteveholmes
11/05/2015, 6:55 PMhastebrot
11/05/2015, 6:56 PMhastebrot
11/05/2015, 6:57 PMorangy
hastebrot
11/05/2015, 7:02 PMorangy
on
inside given
and not just top-level on
and then inside it on
again, etc?orangy
hastebrot
11/05/2015, 7:05 PMon()
in an OnSpecContext
(or whatever this could be named).orangy
orangy
orangy
hastebrot
11/05/2015, 7:08 PMhastebrot
11/05/2015, 7:11 PMhastebrot
11/05/2015, 7:24 PMhastebrot
11/05/2015, 7:26 PMorangy
hastebrot
11/05/2015, 7:31 PMorangy
I don't understand the side-effects issues you mentioned.when evaluating hierarchy you have to execute lambdas, so that you get nested “describe” calls, and since they are just lambdas, they could establish some shared state:
describe(“a") {
val db = connect()
describe(“b”) { … use db … }
describe(“c”) { … use db … }
}
As soon as you execute describe(“a”), you get “db” captured in lambdas for b & c, which keeps connection, etcorangy
orangy
val db by lazy { connect() }
orangy
hastebrot
11/05/2015, 7:43 PMorangy
orangy
context(function () {
db = connect()
})
and through this-substitution and using dynamic nature of JS make db
available in nested describes, resetting it before each callorangy
hastebrot
11/05/2015, 8:01 PMclass ConcreteSpec : AbstractSpec({
describe("compare numbers") {
beforeEach {
context["other"] = 12
}
it("should not be equal") {
assert(14 != context["other"])
}
}
})
We could use beforeEach()
, but this makes problems with scoped values. A hashmap like context["other"]
in the above code doesn't make it better.