There is nothing stopping you from using GebConfig.groovy for any arbitrary
configuration but I personally wouldn't as I find it not a clean solution -
you'd be mixing concerns. I wouldn't do it especially as it's relatively
easy to roll your own config using the same mechanism Geb is using which is
available in core Groovy, namely groovy.util.ConfigSlurper which has
support for environment specific configuration.

Rolling your own mechanism would also make it possible for you to have the
behaviour you're asking in 3. You could create the following method at the
top of your config script:

def propertyOrValue(String propertyName, value) {
    System.getProperty(propertyName) ?: value
}

And then you can use it like:

foo {
    bar = propertyOrValue('foo.bar', 'buzz')
}

environments {
    superDuper {
        foo {
            bar = propertyOrValue('foo.bar', 'bizz')
        }
    }
}

If you want to make the propertyOrValue() method reusable because you
envisage having multiple configuration scripts then you could create a base
script class (extends groovy.lang.Script), use
groovy.lang.GroovyShell.parse() together with a custom compiler
configuration (as shown by Mr. Haki at
http://mrhaki.blogspot.co.uk/2011/11/groovy-goodness-create-our-own-script.html)
to compile and initiate your config script with a custom base class and
then pass it to ConfigSlurper.parse(Script).

On Fri, Oct 13, 2017 at 5:45 AM, Samuel Rossinovic <
[email protected]> wrote:

> Hi.
> I'm looking for the recommended approach to add some test configuration.
> This would be arbitrary configuration (not geb's).
>
>    1. Is GebConfig.groovy a good place for such configuration? Or am I
>    expected to roll my own config resource?
>    2. I noticed the following:
>       1.
>
>       browser.config.properties: provides System properties (would allow 
> providing config from the command line, but not from file)
>
>       2.
>
>       browser.config.rawConfig: provides access to GebConfig
>
>       3.
>
>       browser.config.rawConfig.properties: provides access to a properties 
> closure in GebConfig
>
>       Is rawConfig/properties documented parts of Geb's config API? If so, 
> where can I read more about it?
>
>       3. Is there a a way to have configuration properties such that it
>    would have a default value (e.g. in GebConfig's top-level scope), a
>    potential per-env override (under environments.foo) , and will also be
>    overridable from command line?
>
> Thanks,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Geb User Mailing List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/geb-user/0abfdf84-efaf-4ce7-9f35-2a6dbbc1bcbe%40googlegroups.com
> <https://groups.google.com/d/msgid/geb-user/0abfdf84-efaf-4ce7-9f35-2a6dbbc1bcbe%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Geb 
User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/geb-user/CA%2B52dQQ14aXc%3DpCtxYd0yzT48v0KTk_cBrX_Q99yhCL1ARtMSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to