Created
October 23, 2015 13:11
-
-
Save oyvindberg/bb1844cb97b2280d8881 to your computer and use it in GitHub Desktop.
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
import java.io.File | |
import java.net.URL | |
import org.scalatest.{FunSpec, Matchers} | |
import unfiltered.filter.Plan | |
import unfiltered.jetty.Server | |
trait UnfilteredFixture extends FunSpec with Matchers { | |
private val port = unfiltered.util.Port.any | |
val host = dispatch.host("localhost", port) | |
def planToTest: Plan | |
private final def newServer = Server | |
.http(port) | |
.plan(planToTest) | |
.resources(new URL(s"file://${new File( "." ).getCanonicalPath}/web/src/main/webapp")) | |
override final protected def withFixture(test: NoArgTest) = { | |
val server = newServer | |
server.start() | |
try { | |
test() // Invoke the test function | |
} finally { | |
server.stop() | |
server.destroy() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment