Skip to content

Instantly share code, notes, and snippets.

@andresteingress
Last active January 4, 2016 22:19
Show Gist options
  • Save andresteingress/8687069 to your computer and use it in GitHub Desktop.
Save andresteingress/8687069 to your computer and use it in GitHub Desktop.
Cucumber Grails integration
/**
* Enables code completion for Geb inside Cucumber step implementations.
*/
def forwardedMethods = ["go", "to", "via", "at",
"waitFor",
"withAlert", "withNoAlert", "withConfirm", "withNoConfirm",
"download", "downloadStream", "downloadText", "downloadBytes", "downloadContent",
"report", "reportGroup", "cleanReportGroupDir"]
def scriptContext = context(filetypes: ['.groovy'], pathRegexp: ".*/test/cucumber/.*", scope: closureScope())
contributor(scriptContext) {
property name: 'browser', type: 'geb.Browser'
def methods = findClass('geb.Browser').getMethods()
methods.findAll { it.name in forwardedMethods }.each { def browserMethod ->
def params = [:]
for (def param : browserMethod.getParameterList().getParameters()) {
params.put(param.name.toLowerCase(), com.intellij.psi.util.TypeConversionUtil.erasure(param.type).canonicalText)
}
method name: browserMethod.name, type: com.intellij.psi.util.TypeConversionUtil.erasure(browserMethod.returnType).canonicalText, params: params
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment