1

I'm using serverConfig to load properties at runtime into my ratpack app.

ratpack {

serverConfig {
    // Load the environment and system properties
    env()
    sysProps()
    require("/search", SearchConfig)
}

where SearchConfig is

class SearchConfig {
  String limit
}

and the config file is like so

{
 "search": {
     "limit" : 100
  }
 }

For a more complete example, see http://kyleboon.org/blog/2016/01/10/layering-ratpack-configuration/ ).

Basically what I'm doing is passing in a gradle project property to define which JSON file holds the configuration I want, then parsing that JSON file into a hierarchical set of properties (the example above would be something like search.limit).

Is there a way to mimic that in spock?

Steve Anderson
  • 334
  • 1
  • 7
  • I never worked with ratpack and am reluctant to read a full tutorial. Can you provide a concrete piece of sample code? A Spock test doing something and maybe a comment where you would like to read what kind of properties? A sample properties file (Java properties or other format?) would also be helpful. Your question is way too unspecific. Please learn [how to ask a question on SO](http://stackoverflow.com/help/how-to-ask) and provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve). Thank you. If you are too lazy to explain, people will be too lazy to answer. – kriegaex Mar 14 '17 at 17:23
  • Try to create temporary test file with config and set system property with its path before test ... Or you can try [Ratpack's Impositions](https://ratpack.io/manual/current/api/ratpack/impose/Impositions.html) – SDen Apr 13 '17 at 11:40

0 Answers0