Created
June 29, 2016 16:09
-
-
Save Timshel/2c593055abdea78bdac4e35e6b369fb0 to your computer and use it in GitHub Desktop.
Custom `WithApplication` to expose main component
This file contains hidden or 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
package helpers | |
import org.openqa.selenium.WebDriver | |
import org.specs2.execute.{ AsResult, Result } | |
import org.specs2.mutable.Around | |
import org.specs2.specification.Scope | |
import play.api.{ Application, ApplicationLoader, Environment, Mode } | |
import play.core.server.{ NettyServer, ServerProvider } | |
abstract class WithApplication extends Around with Scope { | |
val context = ApplicationLoader.createContext(new Environment(new java.io.File("."), ApplicationLoader.getClass.getClassLoader, Mode.Test)) | |
implicit lazy val rc = new com.mfglabs.RankComponents(context) | |
implicit lazy val app: Application = rc.application | |
def around[T: AsResult](t: => T): Result = { | |
play.api.test.Helpers.running(app)(AsResult.effectively(t)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment