Skip to content

fixed & simplified groovy step snippets #303

merged 1 commit into from Apr 22, 2012

2 participants

hauner commented Apr 21, 2012

the generated groovy snippets do not work out of the box:

When(~"^I run cucumber$") { -> ... }

Error: Indentifier or code block expected, String end expected

the $ is a special character in groovy to embed an expression into a GString, ie. a double quoted string. To disable the groovy $ it has to be escaped...

When(~"^I run cucumber\$") { -> ... }

... or the string has to be quoted with single ticks (to make it a normal String) ...

When(~'^I run cucumber$') { -> ... }

Which has the advantage that the " does not have to be escaped as well. So it is possible to simplify

When(~"^I run cucumber with \"([^\"]*)\"\$") { String arg -> }


When(~'^I run cucumber with "([^"]*)"$') { String arg -> }

I think everyone agrees that this is a lot better.. :-)

@aslakhellesoy aslakhellesoy merged commit 0a6afe5 into cucumber:master Apr 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.