The standard config setup only looks at the current environment. Holders has the same current config as grailsApplication. You have to slurp the config again. Try using ConfigurationHelper. A spock test is below. (Note the sometimes doubled config.config is because the first config is the property (or short name for getConfig() method) and your key contains the second config.)
import grails.test.mixin.TestMixin
import grails.test.mixin.support.GrailsUnitTestMixin
import spock.lang.Specification
import org.codehaus.groovy.grails.commons.cfg.ConfigurationHelper
@TestMixin(GrailsUnitTestMixin)
class ConfigSpec extends Specification {
void "test prod config"() {
def configSlurper = ConfigurationHelper.getConfigSlurper('production',null)
def configObject = configSlurper.parse(grailsApplication.classLoader.loadClass(grailsApplication.CONFIG_CLASS))
expect:
configObject.config.url == "http://prod.lan"
}
void "test dev config"() {
def configSlurper = ConfigurationHelper.getConfigSlurper('development',null)
def configObject = configSlurper.parse(grailsApplication.classLoader.loadClass(grailsApplication.CONFIG_CLASS))
expect:
configObject.config.url == "http://local"
}
void "test grailsApplication config"() {
expect:
grailsApplication.config.config.url == "http://test.lan"
}
void "test Holders config"() {
expect:
grails.util.Holders.config.config.url == "http://test.lan"
}
}