Skip to content

Instantly share code, notes, and snippets.

@Timshel
Created June 29, 2016 16:09
Show Gist options
  • Save Timshel/2c593055abdea78bdac4e35e6b369fb0 to your computer and use it in GitHub Desktop.
Save Timshel/2c593055abdea78bdac4e35e6b369fb0 to your computer and use it in GitHub Desktop.
Custom `WithApplication` to expose main component
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