Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed & simplified groovy step snippets #303

Merged
merged 1 commit into from
Apr 22, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class GroovySnippet implements Snippet {
@Override
public String template() {
return "{0}(~\"{1}\") '{' {3}->\n" +
return "{0}(~''{1}'') '{' {3}->\n" +
" // {4}\n" +
" throw new PendingException()\n" +
"'}'\n";
Expand Down Expand Up @@ -46,6 +46,6 @@ public String namedGroupEnd() {

@Override
public String escapePattern(String pattern) {
return pattern.replaceAll("\"", "\\\\\"");
return pattern;
}
}
20 changes: 10 additions & 10 deletions groovy/src/test/java/cucumber/runtime/groovy/GroovySnippetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class GroovySnippetTest {
@Test
public void generatesPlainSnippet() {
String expected = "" +
"Given(~\"^I have (\\d+) cukes in my \\\"([^\\\"]*)\\\" belly$\") { int arg1, String arg2 ->\n" +
"Given(~'^I have (\\d+) cukes in my \"([^\"]*)\" belly$') { int arg1, String arg2 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException()\n" +
"}\n";
Expand All @@ -30,7 +30,7 @@ public void generatesPlainSnippet() {
@Test
public void generatesCopyPasteReadyStepSnippetForNumberParameters() throws Exception {
String expected = "" +
"Given(~\"^before (\\d+) after$\") { int arg1 ->\n" +
"Given(~'^before (\\d+) after$') { int arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException()\n" +
"}\n";
Expand All @@ -41,7 +41,7 @@ public void generatesCopyPasteReadyStepSnippetForNumberParameters() throws Excep
@Test
public void generatesCopyPasteReadySnippetWhenStepHasIllegalJavaIdentifierChars() {
String expected = "" +
"Given(~\"^I have (\\d+) cukes in: my \\\"([^\\\"]*)\\\" red-belly!$\") { int arg1, String arg2 ->\n" +
"Given(~'^I have (\\d+) cukes in: my \"([^\"]*)\" red-belly!$') { int arg1, String arg2 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException()\n" +
"}\n";
Expand All @@ -52,7 +52,7 @@ public void generatesCopyPasteReadySnippetWhenStepHasIllegalJavaIdentifierChars(
@Test
public void generatesCopyPasteReadySnippetWhenStepHasIntegersInsideStringParameter() {
String expected = "" +
"Given(~\"^the DI system receives a message saying \\\"([^\\\"]*)\\\"$\") { String arg1 ->\n" +
"Given(~'^the DI system receives a message saying \"([^\"]*)\"$') { String arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException()\n" +
"}\n";
Expand All @@ -62,7 +62,7 @@ public void generatesCopyPasteReadySnippetWhenStepHasIntegersInsideStringParamet
@Test
public void generatesSnippetWithEscapedDollarSigns() {
String expected = "" +
"Given(~\"^I have \\$(\\d+)$\") { int arg1 ->\n" +
"Given(~'^I have \\$(\\d+)$') { int arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException()\n" +
"}\n";
Expand All @@ -72,7 +72,7 @@ public void generatesSnippetWithEscapedDollarSigns() {
@Test
public void generatesSnippetWithEscapedParentheses() {
String expected = "" +
"Given(~\"^I have (\\d+) cukes \\(maybe more\\)$\") { int arg1 ->\n" +
"Given(~'^I have (\\d+) cukes \\(maybe more\\)$') { int arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException()\n" +
"}\n";
Expand All @@ -82,7 +82,7 @@ public void generatesSnippetWithEscapedParentheses() {
@Test
public void generatesSnippetWithEscapedBrackets() {
String expected = "" +
"Given(~\"^I have (\\d+) cukes \\[maybe more\\]$\") { int arg1 ->\n" +
"Given(~'^I have (\\d+) cukes \\[maybe more\\]$') { int arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException()\n" +
"}\n";
Expand All @@ -92,7 +92,7 @@ public void generatesSnippetWithEscapedBrackets() {
@Test
public void generatesSnippetWithDocString() {
String expected = "" +
"Given(~\"^I have:$\") { String arg1 ->\n" +
"Given(~'^I have:$') { String arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException()\n" +
"}\n";
Expand All @@ -102,7 +102,7 @@ public void generatesSnippetWithDocString() {
@Test
public void generatesSnippetWithDataTable() {
String expected = "" +
"Given(~\"^I have:$\") { DataTable arg1 ->\n" +
"Given(~'^I have:$') { DataTable arg1 ->\n" +
" // Express the Regexp above with the code you wish you had\n" +
" throw new PendingException()\n" +
"}\n";
Expand All @@ -124,4 +124,4 @@ private String snippetForDataTable(String name, List<DataTableRow> dataTable) {
Step step = new Step(NO_COMMENTS, "Given ", name, 0, dataTable, null);
return new SnippetGenerator(new GroovySnippet()).getSnippet(step);
}
}
}