Skip to content

Instantly share code, notes, and snippets.

@zedar
Last active August 29, 2015 14:07
Show Gist options
  • Save zedar/19436dcb700f3fe05ad9 to your computer and use it in GitHub Desktop.
Save zedar/19436dcb700f3fe05ad9 to your computer and use it in GitHub Desktop.
Ratpack tests and external .properties

Ratpack tests are based on Spock Framework.

To externalize properties from test cases, create new file in:

$ touch src/tests/resources/hipchat.properties

Put properties into the file:

auth_token=VALUE_OF_HIPCHAT_AUTH_TOKEN

In test case add reference to properties and common setup() method. Inside side load properties file from classs path

// src/test/groovy/HipChatApiTest.groovy
import spock.lang.Specification

class HipChatApiTest extends Specification {
  Properties properties
    
  def setup() {
      properties = new Properties()
      properties.load(getClass().getClassLoader().getResourceAsStream("hipchat.properties"))
  }
  
  def "Send new hipchat notification"() {
      given:
          String hipchatUrl = "https://api.hipchat.com/v2/room/online4m.com/notification?auth_token=${properties.auth_token}"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment