Skip to content

Commit

Permalink
New Snippet text, closes #618.
Browse files Browse the repository at this point in the history
Change to the new Snippet text. Update History.md.
Fix a one off error in JRubySnippet.java.
  • Loading branch information
brasmusson committed Nov 2, 2013
1 parent 30de1c6 commit 8d52511
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/cucumber/runtime/jruby/JRubySnippet.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public String tableHint() {
public String arguments(List<Class<?>> argumentTypes) {
StringBuilder sb = new StringBuilder(argumentTypes.isEmpty() ? "" : "|");
for (int n = 0; n < argumentTypes.size(); n++) {
if (n > 1) {
if (n > 0) {
sb.append(", ");
}
sb.append("arg").append(n + 1);
Expand Down
32 changes: 32 additions & 0 deletions src/test/java/cucumber/runtime/jruby/JRubySnippetTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cucumber.runtime.jruby;

import cucumber.runtime.snippets.SnippetGenerator;
import gherkin.formatter.model.Comment;
import gherkin.formatter.model.Step;
import org.junit.Test;

import java.util.Collections;
import java.util.List;

import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;

public class JRubySnippetTest {

private static final List<Comment> NO_COMMENTS = Collections.emptyList();

@Test
public void generatesPlainSnippet() {
String expected = "" +
"Given /^I have (\\d+) cukes in my \"([^\"]*)\" belly$/ do |arg1, arg2|\n" +
" # Write code here that turns the phrase above into concrete actions\n" +
" pending\n" +
"end\n";
assertEquals(expected, snippetFor("I have 4 cukes in my \"big\" belly"));
}

private String snippetFor(String name) {
Step step = new Step(NO_COMMENTS, "Given ", name, 0, null, null);
return new SnippetGenerator(new JRubySnippet()).getSnippet(step, null);
}
}

0 comments on commit 8d52511

Please sign in to comment.