These are chat archives for etorreborre/specs2

24th
Jul 2018
vito-c
@vito-c
Jul 24 2018 06:24
is there a way to do something like this:
class ThingToTest {
    def doTheThing() = {
        println("the thing")
    }
}
val thingToTest = new ThingToTest
"the thing" should {
    "do something" in thingToTest {
        doTheThing()
    }
}
I'm trying to avoid new-ing up a new ThingToTest class all the time ie:
"the thing" should {
    "do something" in new ThingToTest {
        doTheThing()
    }
}
Eric Torreborre
@etorreborre
Jul 24 2018 06:32
You could try to have an ˋapplymethod on ˋThingToTest but I don't think this will work without parentheses
vito-c
@vito-c
Jul 24 2018 06:43
oh no the thing is i'm trying to reuse that val
in the tests
the compiler error that I get if the above is run is not found: value doTheThing
I was trying to be generic in the naming I used in this example above but I guess that made it a lil hard to read
Eric Torreborre
@etorreborre
Jul 24 2018 06:58
Also have you had a look at the ForEach trait?
vito-c
@vito-c
Jul 24 2018 07:07
ic seems like ForEach might do the trick. I'll have to figure out what >> does though :D
Eric Torreborre
@etorreborre
Jul 24 2018 07:08
This is a synonym for ˋin`
vito-c
@vito-c
Jul 24 2018 07:17
ah ok thanks!