This is a scala wrapper for moco, based on the unmaintained moco-scala by Nicholas Ren. In contrast to the the previous versions by Nicholas, the Moco server does not have mutable state.
libraryDependencies += "org.treppo" %% "moco-scala" % "0.5.2" % Test
// Import dependencies
import org.treppo.mocoscala.dsl.Moco._
// Create server with port
val theServer = server(8080) when { uri("/hello") } respond { status(200) }
// Create server with random port
val theServer = server when { uri("/hello") } respond { status(200) }
// Running server and test your stuff
theServer running { uri: URI =>
assert(SomeHttpClient().url(uri).get.status === 200)
}
Detailed feature documentation can be found in the doc/api.md
Also, please refer to functional tests.
Questions, suggestions or pull requests are more than welcome in the Issues section.
Licensed under the MIT license