Skip to content

Commit

Permalink
Fixed StepDefinitionMatch to work with StepDefinitions that return nu…
Browse files Browse the repository at this point in the history
…ll for getParameterTypes (e.g. ClojureStepDefinition)
  • Loading branch information
nilswloka committed Mar 12, 2012
1 parent 2f8ec01 commit 47aaf2f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ Feature: Cukes
Scenario: in the belly
Given I have 4 cukes in my belly
Then there are 4 cukes in my belly

Scenario: in the belly (list)
Given I have this many cukes in my belly:
| 13 |
Then there are 13 cukes in my belly
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
(Given #"^I have (\d+) cukes in my belly$"
#(eat (Float. %1)))

(Given #"^I have this many cukes in my belly:$"
#(doseq [x (.raw %1)] (eat (Float. (first x)))))

(When #"^there are (\d+) cukes in my belly$"
(fn [expected]
(assert (= (last-meal) (Float. expected)))))
Expand Down
13 changes: 10 additions & 3 deletions core/src/main/java/cucumber/runtime/StepDefinitionMatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,16 @@ private Object tableArgument(Step step, int argIndex, XStream xStream, String da
}

private Type getGenericListType(int argIndex) {
ParameterType parameterType = stepDefinition.getParameterTypes().get(argIndex);
Type[] actualTypeArguments = parameterType.getActualTypeArguments();
return actualTypeArguments != null && actualTypeArguments.length > 0 ? actualTypeArguments[0] : null;
Type result = null;
List<ParameterType> parameterTypes = stepDefinition.getParameterTypes();
if (parameterTypes != null) {
ParameterType parameterType = parameterTypes.get(argIndex);
Type[] actualTypeArguments = parameterType.getActualTypeArguments();
if (actualTypeArguments != null && actualTypeArguments.length > 0) {
result = actualTypeArguments[0];
}
}
return result;
}

public Throwable removeFrameworkFramesAndAppendStepLocation(Throwable error, StackTraceElement stepLocation) {
Expand Down

0 comments on commit 47aaf2f

Please sign in to comment.