Permalink
Browse files

Fixed bug where -getSnippet in clj.clj received only the step parameter.

cucumber.runtime.UndefinedStepsTracker actually calls the Backend
instances with 2 parameters--Step and FunctionNameGenerator--but
Clojure's Backend implementation only accepts one.

Instead of testing generation of Clojure Snippet with a test-only
ClojureSnippet instance, ClojureSnippetTest now tests the real
implementation in clj.clj.
  • Loading branch information...
1 parent 77a93d1 commit 5e3d2fdc546d066300b0f99e6de93563843aaa3b @shaolang shaolang committed Dec 19, 2013
@@ -57,8 +57,8 @@
(defn- -disposeWorld [cljb])
-(defn- -getSnippet [cljb step]
- (.getSnippet snippet-generator step))
+(defn- -getSnippet [cljb step _]
+ (.getSnippet snippet-generator step nil))
(defn- -setUnreportedStepExecutor [cljb executor]
"executor")
@@ -1,45 +0,0 @@
-package cucumber.runtime.clojure;
-
-import cucumber.runtime.snippets.Snippet;
-
-import java.util.List;
-
-import static cucumber.runtime.snippets.SnippetGenerator.untypedArguments;
-
-/**
- * This class is only here to test clojure snippets in isolation.
- * Keep the template in sync with clj.clj
- */
-public class ClojureSnippet implements Snippet {
- @Override
- public String template() {
- return "({0} #\"{1}\" [{3}]\n" +
- " (comment {4} )\n" +
- " (throw (cucumber.api.PendingException.)))\n";
- }
-
- @Override
- public String tableHint() {
- return null;
- }
-
- @Override
- public String arguments(List<Class<?>> argumentTypes) {
- return untypedArguments(argumentTypes).replaceAll(",", "");
- }
-
- @Override
- public String namedGroupStart() {
- return null;
- }
-
- @Override
- public String namedGroupEnd() {
- return null;
- }
-
- @Override
- public String escapePattern(String pattern) {
- return pattern.replace("\"", "\\\"");
- }
-}
@@ -1,6 +1,6 @@
package cucumber.runtime.clojure;
-import cucumber.runtime.snippets.SnippetGenerator;
+import cucumber.runtime.clj.Backend;
import gherkin.formatter.model.Comment;
import gherkin.formatter.model.DataTableRow;
import gherkin.formatter.model.Step;
@@ -18,7 +18,7 @@
@Test
public void generatesPlainSnippet() {
Step step = new Step(NO_COMMENTS, "Given ", "I have 4 cukes in my \"big\" belly", 0, null, null);
- String snippet = new SnippetGenerator(new ClojureSnippet()).getSnippet(step, null);
+ String snippet = (new Backend(null)).getSnippet(step, null);
String expected = "" +
"(Given #\"^I have (\\d+) cukes in my \\\"([^\\\"]*)\\\" belly$\" [arg1 arg2]\n" +
" (comment Write code here that turns the phrase above into concrete actions )\n" +
@@ -30,7 +30,7 @@ public void generatesPlainSnippet() {
public void generatesSnippetWithDataTable() {
List<DataTableRow> dataTable = asList(new DataTableRow(NO_COMMENTS, asList("col1"), 1));
Step step = new Step(NO_COMMENTS, "Given ", "I have:", 0, dataTable, null);
- String snippet = new SnippetGenerator(new ClojureSnippet()).getSnippet(step, null);
+ String snippet = (new Backend(null)).getSnippet(step, null);
String expected = "" +
"(Given #\"^I have:$\" [arg1]\n" +
" (comment Write code here that turns the phrase above into concrete actions )\n" +

0 comments on commit 5e3d2fd

Please sign in to comment.