A highly configurable
EmbeddedApp
implementation that allows the application to be defined in code at runtime.
This implementation is usually sufficient for testing Ratpack modules or extensions.
import ratpack.test.embed.BaseDirBuilder
import ratpack.session.SessionModule
import ratpack.groovy.test.embed.GroovyEmbeddedApp
GroovyEmbeddedApp.build {
baseDir {
BaseDirBuilder.tmpDir().build {
it.file "public/foo.txt", "bar"
}
}
launchConfig {
development true
other "some.other.property": "value"
}
// Configure the module registry
bindings {
add new SessionModule()
}
// Use the GroovyChain DSL for defining the application handlers
handlers {
get {
render "root"
}
assets "public"
}
}.test {
assert it.getText() == "root"
assert it.getText("foo.txt") == "bar"
}