Created
October 25, 2013 19:37
-
-
Save sergiomichels/7160616 to your computer and use it in GitHub Desktop.
Set the Locale of your integration test
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
import grails.plugin.spock.IntegrationSpec | |
import org.springframework.web.context.request.RequestContextHolder | |
class MyTestSpec extends IntegrationSpec { | |
/* Normally in your code you will use something like RequestContextUtils.getLocale(request) to get's the Locale to | |
* be used. Here we set the locale that will be returned by RCU to our tests. | |
*/ | |
def setup() { | |
//get's the instance of the mock | |
def request = RequestContextHolder.currentRequestAttributes().request | |
//and then set your locale | |
request.addPreferredLocale(new Locale("pt","BR")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment