Created
July 27, 2015 23:02
-
-
Save danhyun/398277d9ffdc83c4e093 to your computer and use it in GitHub Desktop.
Registering Guice Modules via GroovyEmbeddedApp
This file contains 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 ratpack.groovy | |
import com.google.inject.AbstractModule | |
import ratpack.groovy.test.embed.GroovyEmbeddedApp | |
import ratpack.guice.Guice | |
import spock.lang.Specification | |
class EmbeddedSpec extends Specification { | |
def "GroovyEmbeddedApp with Guice Module"() { | |
given: | |
def app = GroovyEmbeddedApp.of { | |
registry(Guice.registry{ spec -> | |
spec.module new AbstractModule() { | |
@Override | |
protected void configure() { | |
bind(String).toInstance("World") | |
} | |
} | |
}) | |
handlers { | |
all { String s -> | |
render("Hello, $s!" as String) | |
} | |
} | |
} | |
expect: | |
app.test { client -> | |
assert client.text == 'Hello, World!' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment