My web-app utilizes Geb for functional testing.
It is a non-english application, all page messages being received from i18n message bundle.
How to make Geb work with internationalized messages?
The Grails RemoteControl plugin allows remote access to a running Grails application. In a functional test setting it can be used to read and change configuration settings, access the application context including the message source, … .
The code below is added to a common base class for all our Geb specifications/tests that can be used in an individual test to retrieve an internationalized message:
class BaseTest/Spec {
RemoteControl remoteControl = new RemoteControl()
String msg(String msgKey, args = null, locale = defaultLocale) {
if (args != null) {
args = args as Object[]
}
return remoteControl.exec {
ctx.messageSource.getMessage(msgKey, args, locale)
}
}
}