These are chat archives for etorreborre/specs2

12th
Mar 2017
G. Richard Bellamy
@rbellamy
Mar 12 2017 01:56
I'm looking for some examples of using Contexts with Acceptance-style testing - and notice that all the contexts are part of the mutable namespace, which is a pretty big signal that they're best not used with acceptance tests...
is there some docs I could read that talk about Contexts in relation to Acceptance tests?
since clearly I'm in need of further education...
Eric Torreborre
@etorreborre
Mar 12 2017 09:28
hi @rbellamy I am not sure that “context” are actually that useful. What is your use case here? Do you need to share some state between examples? Do you need to access a bunch of objects in all examples?
G. Richard Bellamy
@rbellamy
Mar 12 2017 16:49
@etorreborre thanks for responding. I'm trying to understand how I would ensure each spec, or example, gets a fresh Scaldi Module (e.g. implicit inj: Injector)
I've seen several examples of such an animal with the Unit Test style, and I've been reading about the Acceptance Test style and Contexts (e.g. Context, context object and Fixture[T]), but am having a difficult time finding a pattern that doesn't look like I used a shotgun...
Eric Torreborre
@etorreborre
Mar 12 2017 20:43
I think that you can use the ForEach trait in that case
class MySpec extends ForEach[MyModule] { def is = s2"""
   do something $here
"""
   def here = { myModule: myModule => 
      ok
   }

   def foreach[R : AsResult](f: MyModule => R): Result = 
      AsResult(f(new MyModule))
}
G. Richard Bellamy
@rbellamy
Mar 12 2017 23:16
@etorreborre that's actually where I landed! Nice... thanks for the validation