Skip to content

Commit

Permalink
[Rhino] Updated rhino for the use of Gherkin v4.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
brasmusson committed Dec 18, 2016
1 parent 7841adf commit d50a9d9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions rhino/src/main/java/cucumber/runtime/rhino/RhinoBackend.java
Expand Up @@ -8,7 +8,7 @@
import cucumber.runtime.io.ResourceLoader; import cucumber.runtime.io.ResourceLoader;
import cucumber.runtime.snippets.FunctionNameGenerator; import cucumber.runtime.snippets.FunctionNameGenerator;
import cucumber.runtime.snippets.SnippetGenerator; import cucumber.runtime.snippets.SnippetGenerator;
import gherkin.formatter.model.Step; import gherkin.pickles.PickleStep;
import org.mozilla.javascript.Context; import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function; import org.mozilla.javascript.Function;
import org.mozilla.javascript.NativeFunction; import org.mozilla.javascript.NativeFunction;
Expand Down Expand Up @@ -90,8 +90,8 @@ public void registerWorld(Function buildWorldFn, Function disposeWorldFn) {
} }


@Override @Override
public String getSnippet(Step step, FunctionNameGenerator functionNameGenerator) { public String getSnippet(PickleStep step, String keyword, FunctionNameGenerator functionNameGenerator) {
return snippetGenerator.getSnippet(step, functionNameGenerator); return snippetGenerator.getSnippet(step, keyword, functionNameGenerator);
} }


private StackTraceElement jsLocation() { private StackTraceElement jsLocation() {
Expand Down
@@ -1,8 +1,8 @@
package cucumber.runtime.rhino; package cucumber.runtime.rhino;


import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import gherkin.TagExpression; import cucumber.runtime.TagExpression;
import gherkin.formatter.model.Tag; import gherkin.pickles.PickleTag;


import java.util.Collection; import java.util.Collection;


Expand Down Expand Up @@ -51,7 +51,7 @@ public Object call() throws Throwable {
} }


@Override @Override
public boolean matches(Collection<Tag> tags) { public boolean matches(Collection<PickleTag> tags) {
return tagExpression.evaluate(tags); return tagExpression.evaluate(tags);
} }


Expand Down
Expand Up @@ -2,9 +2,8 @@


import cucumber.runtime.ParameterInfo; import cucumber.runtime.ParameterInfo;
import cucumber.runtime.StepDefinition; import cucumber.runtime.StepDefinition;
import gherkin.I18n; import cucumber.runtime.Argument;
import gherkin.formatter.Argument; import gherkin.pickles.PickleStep;
import gherkin.formatter.model.Step;
import org.mozilla.javascript.Context; import org.mozilla.javascript.Context;
import org.mozilla.javascript.JavaScriptException; import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.NativeFunction; import org.mozilla.javascript.NativeFunction;
Expand Down Expand Up @@ -35,8 +34,8 @@ public RhinoStepDefinition(Context cx, Scriptable scope, Global jsStepDefinition
this.argumentsFromFunc = argumentsFromFunc; this.argumentsFromFunc = argumentsFromFunc;
} }


public List<Argument> matchedArguments(Step step) { public List<Argument> matchedArguments(PickleStep step) {
NativeJavaObject args = (NativeJavaObject) argumentsFromFunc.call(cx, scope, jsStepDefinition, new Object[]{step.getName(), this}); NativeJavaObject args = (NativeJavaObject) argumentsFromFunc.call(cx, scope, jsStepDefinition, new Object[]{step.getText(), this});
return args == null ? null : unwrap(args); return args == null ? null : unwrap(args);
} }


Expand All @@ -59,7 +58,7 @@ public ParameterInfo getParameterType(int n, Type argumentType) {
return new ParameterInfo(argumentType, null, null, null); return new ParameterInfo(argumentType, null, null, null);
} }


public void execute(I18n i18n, Object[] args) throws Throwable { public void execute(String language, Object[] args) throws Throwable {
try { try {
bodyFunc.call(cx, scope, scope, args); bodyFunc.call(cx, scope, scope, args);
} catch (JavaScriptException e) { } catch (JavaScriptException e) {
Expand Down
2 changes: 1 addition & 1 deletion rhino/src/main/resources/cucumber/runtime/rhino/dsl.js
Expand Up @@ -8,7 +8,7 @@ var registerStepDefinition = function(regexp, bodyFunc) {
for (var i = 1; i < match.length; i++) { for (var i = 1; i < match.length; i++) {
var arg = match[i]; var arg = match[i];
offset = s.indexOf(arg, offset); offset = s.indexOf(arg, offset);
arguments.add(new Packages.gherkin.formatter.Argument(offset, arg)); arguments.add(new Packages.cucumber.runtime.Argument(offset, arg));
} }
return arguments; return arguments;
} else { } else {
Expand Down
@@ -1,8 +1,9 @@
package cucumber.runtime.rhino; package cucumber.runtime.rhino;


import cucumber.runtime.snippets.SnippetGenerator; import cucumber.runtime.snippets.SnippetGenerator;
import gherkin.formatter.model.Comment; import gherkin.pickles.Argument;
import gherkin.formatter.model.Step; import gherkin.pickles.PickleLocation;
import gherkin.pickles.PickleStep;
import org.junit.Test; import org.junit.Test;


import java.util.Collections; import java.util.Collections;
Expand All @@ -22,7 +23,7 @@ public void generatesPlainSnippet() {
} }


private String snippetFor(String name) { private String snippetFor(String name) {
Step step = new Step(Collections.<Comment>emptyList(), "Given ", name, 0, null, null); PickleStep step = new PickleStep(name, Collections.<Argument>emptyList(), Collections.<PickleLocation>emptyList());
return new SnippetGenerator(new JavaScriptSnippet()).getSnippet(step, null); return new SnippetGenerator(new JavaScriptSnippet()).getSnippet(step, "Given", null);
} }
} }
Expand Up @@ -4,7 +4,7 @@
import cucumber.runtime.RuntimeGlue; import cucumber.runtime.RuntimeGlue;
import cucumber.runtime.io.MultiLoader; import cucumber.runtime.io.MultiLoader;
import cucumber.runtime.io.ResourceLoader; import cucumber.runtime.io.ResourceLoader;
import gherkin.formatter.model.Tag; import gherkin.pickles.PickleTag;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
Expand Down Expand Up @@ -95,15 +95,15 @@ private void assertHook(HookDefinition hookDefinition, String[] tagExprs, int or


RhinoHookDefinition rhinoHook = (RhinoHookDefinition) hookDefinition; RhinoHookDefinition rhinoHook = (RhinoHookDefinition) hookDefinition;


List<Tag> tags = new ArrayList<Tag>(); List<PickleTag> tags = new ArrayList<PickleTag>();


for (String tagExpr : tagExprs) { for (String tagExpr : tagExprs) {
tags.add(new Tag(tagExpr, null)); tags.add(new PickleTag(null, tagExpr));
} }


assertTrue(rhinoHook.getTagExpression().evaluate(tags)); assertTrue(rhinoHook.getTagExpression().evaluate(tags));
assertThat(rhinoHook.getOrder(), equalTo(order)); assertThat(rhinoHook.getOrder(), equalTo(order));
assertThat(rhinoHook.getTimeout(), equalTo(timeoutMillis)); assertThat(rhinoHook.getTimeout(), equalTo(timeoutMillis));
} }


} }

0 comments on commit d50a9d9

Please sign in to comment.