Skip to content

Instantly share code, notes, and snippets.

@mariussoutier
Forked from cessationoftime/AkkaSpecification.scala
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariussoutier/11138244 to your computer and use it in GitHub Desktop.
Save mariussoutier/11138244 to your computer and use it in GitHub Desktop.
Test Akka from Specs2, versions as of Play 2.2.x
import org.specs2.mutable._
import org.specs2.specification._
import org.specs2.matcher._
import org.specs2.execute._
import org.specs2.control.Debug
import org.specs2.main.ArgumentsShortcuts
import akka.testkit.TestKitBase
import akka.actor.ActorSystem
trait AkkaSpecification extends SpecificationStructure
with org.specs2.mutable.FragmentsBuilder
with org.specs2.mutable.SpecificationInclusion
with ArgumentsArgs
with ArgumentsShortcuts
with MustMatchers
with StandardResults
with StandardMatchResults
with Contexts
with TestKitBase {
def is = specFragments
implicit lazy val system = ActorSystem()
/** transform a context to a result to allow the implicit passing of a context to each example */
implicit def contextToResult[T](t: MatchResult[T])(implicit context: Context = defaultContext): Result = context(asResult(t))
/** use an available outside context to transform a function returning a MatchResult into a result */
implicit def outsideFunctionToResult[T, S](implicit o: Outside[T]) = (f: T => MatchResult[S]) => { o((t1: T) => f(t1).toResult) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment