Skip to content

Commit 6456704

Browse files
committed
Added missing argument in Jython snippets. Closes #324
1 parent 3b3f201 commit 6456704

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

History.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## [Git master](https://github.com/cucumber/cucumber-jvm/compare/v1.0.7...master)
22

3+
* [Jython] Added missing `self` argument in Jython snippets. ([#324](https://github.com/cucumber/cucumber-jvm/issues/324) Aslak Hellesøy)
34
* [Scala] Fixed regression from v1.0.6 in Scala module - glue code wasn't loaded at all. ([#321](https://github.com/cucumber/cucumber-jvm/issues/321) Aslak Hellesøy)
45

56
## [1.0.8](https://github.com/cucumber/cucumber-jvm/compare/v1.0.7...v1.0.8)

jython/src/main/java/cucumber/runtime/jython/JythonSnippet.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public String tableHint() {
2424

2525
@Override
2626
public String arguments(List<Class<?>> argumentTypes) {
27-
return untypedArguments(argumentTypes);
27+
String args = untypedArguments(argumentTypes);
28+
return args.equals("") ? "self" : "self, " + args;
2829
}
2930

3031
@Override

jython/src/test/java/cucumber/runtime/jython/JythonSnippetTest.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,27 @@
1212
public class JythonSnippetTest {
1313

1414
@Test
15-
public void generatesPlainSnippet() {
15+
public void generatesSnippetWithTwoArgs() {
1616
String expected = "" +
1717
"@Given('^I have (\\d+) cukes in my \"([^\"]*)\" belly$')\n" +
18-
"def I_have_cukes_in_my_belly(arg1, arg2):\n" +
18+
"def I_have_cukes_in_my_belly(self, arg1, arg2):\n" +
1919
" # Express the Regexp above with the code you wish you had\n" +
2020
" raise(PendingException())\n" +
2121
"";
2222
assertEquals(expected, snippetFor("I have 4 cukes in my \"big\" belly"));
2323
}
2424

25+
@Test
26+
public void generatesSnippetWithZeroArgs() {
27+
String expected = "" +
28+
"@Given('^I have no cukes belly$')\n" +
29+
"def I_have_no_cukes_belly(self):\n" +
30+
" # Express the Regexp above with the code you wish you had\n" +
31+
" raise(PendingException())\n" +
32+
"";
33+
assertEquals(expected, snippetFor("I have no cukes belly"));
34+
}
35+
2536
private String snippetFor(String name) {
2637
Step step = new Step(Collections.<Comment>emptyList(), "Given ", name, 0, null, null);
2738
return new SnippetGenerator(new JythonSnippet()).getSnippet(step);

0 commit comments

Comments
 (0)