Created
October 23, 2013 04:08
-
-
Save etorreborre/7112484 to your computer and use it in GitHub Desktop.
Stack Around contexts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.specs2._ | |
import matcher._ | |
import execute._ | |
import specification._ | |
// the "larger" context must be mixed-in last | |
class MySpec extends mutable.Specification with Db with Web { | |
// prints | |
// on the web | |
// in the db | |
//run | |
"run in the db, on the web" >> { "run".pp; ok } | |
} | |
trait AroundBase extends AroundExample { | |
def around[R : AsResult](r: =>R) = { | |
AsResult(r) | |
} | |
} | |
trait Db extends AroundBase { | |
override def around[R : AsResult](r: =>R) = { | |
println("in the db") | |
AsResult(super.around(r)) | |
} | |
} | |
trait Web extends AroundBase { | |
override def around[R : AsResult](r: =>R) = { | |
println("on the web") | |
AsResult(super.around(r)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment