Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

Commit

Permalink
Merge pull request #234 from os97673/jruby-improvements
Browse files Browse the repository at this point in the history
Jruby improvements
  • Loading branch information
os97673 committed Mar 1, 2013
2 parents 70c847d + 95f013b commit 8871df0
Show file tree
Hide file tree
Showing 57 changed files with 3,781 additions and 3,694 deletions.
132 changes: 66 additions & 66 deletions features/.cucumber/stepdefs.json
Original file line number Diff line number Diff line change
@@ -1,243 +1,243 @@
[
{
"file_colon_line": "features/step_definitions/eyeball_steps.rb:1",
"flags": "",
"source": "^they have arrived$",
"flags": "",
"file_colon_line": "features/step_definitions/eyeball_steps.rb:1",
"steps": [
{
"name": "they have arrived",
"args": [

],
"name": "they have arrived"
]
}
]
},
{
"file_colon_line": "features/step_definitions/gherkin_steps.rb:1",
"flags": "",
"source": "^a \"(ruby|native)\" \"([^\\\"]*)\" parser$",
"flags": "",
"file_colon_line": "features/step_definitions/gherkin_steps.rb:1",
"steps": [

]
},
{
"file_colon_line": "features/step_definitions/gherkin_steps.rb:5",
"flags": "",
"source": "^the\\ following\\ text\\ is\\ parsed:$",
"flags": "",
"file_colon_line": "features/step_definitions/gherkin_steps.rb:5",
"steps": [
{
"name": "the following text is parsed:",
"args": [

],
"name": "the following text is parsed:"
]
}
]
},
{
"file_colon_line": "features/step_definitions/gherkin_steps.rb:9",
"flags": "",
"source": "^there\\ should\\ be\\ no\\ parse\\ errors$",
"flags": "",
"file_colon_line": "features/step_definitions/gherkin_steps.rb:9",
"steps": [
{
"name": "there should be no parse errors",
"args": [

],
"name": "there should be no parse errors"
]
}
]
},
{
"file_colon_line": "features/step_definitions/gherkin_steps.rb:13",
"flags": "",
"source": "^there should be a parse error on (line \\d+)$",
"flags": "",
"file_colon_line": "features/step_definitions/gherkin_steps.rb:13",
"steps": [
{
"name": "there should be a parse error on line 1",
"args": [
{
"offset": 33,
"val": "line 1"
}
],
"name": "there should be a parse error on line 1"
]
}
]
},
{
"file_colon_line": "features/step_definitions/gherkin_steps.rb:17",
"flags": "",
"source": "^there should be parse errors on (lines .*)$",
"flags": "",
"file_colon_line": "features/step_definitions/gherkin_steps.rb:17",
"steps": [
{
"name": "there should be parse errors on lines 1 and 2",
"args": [
{
"offset": 32,
"val": "lines 1 and 2"
}
],
"name": "there should be parse errors on lines 1 and 2"
]
},
{
"name": "there should be parse errors on lines 1 through 3",
"args": [
{
"offset": 32,
"val": "lines 1 through 3"
}
],
"name": "there should be parse errors on lines 1 through 3"
]
},
{
"name": "there should be parse errors on lines 10 and 17",
"args": [
{
"offset": 32,
"val": "lines 10 and 17"
}
],
"name": "there should be parse errors on lines 10 and 17"
]
},
{
"name": "there should be parse errors on lines 3 and 5",
"args": [
{
"offset": 32,
"val": "lines 3 and 5"
}
],
"name": "there should be parse errors on lines 3 and 5"
]
},
{
"name": "there should be parse errors on lines 5, 10 and 12",
"args": [
{
"offset": 32,
"val": "lines 5, 10 and 12"
}
],
"name": "there should be parse errors on lines 5, 10 and 12"
]
}
]
},
{
"file_colon_line": "features/step_definitions/json_formatter_steps.rb:13",
"flags": "",
"source": "^a JSON formatter$",
"flags": "",
"file_colon_line": "features/step_definitions/json_formatter_steps.rb:13",
"steps": [

]
},
{
"file_colon_line": "features/step_definitions/json_formatter_steps.rb:18",
"flags": "",
"source": "^the outputted JSON should be:$",
"flags": "",
"file_colon_line": "features/step_definitions/json_formatter_steps.rb:18",
"steps": [
{
"name": "the outputted JSON should be:",
"args": [

],
"name": "the outputted JSON should be:"
]
}
]
},
{
"file_colon_line": "features/step_definitions/json_parser_steps.rb:5",
"flags": "",
"source": "^a PrettyFormatter$",
"flags": "",
"file_colon_line": "features/step_definitions/json_parser_steps.rb:5",
"steps": [

]
},
{
"file_colon_line": "features/step_definitions/json_parser_steps.rb:10",
"flags": "",
"source": "^a JSON lexer$",
"flags": "",
"file_colon_line": "features/step_definitions/json_parser_steps.rb:10",
"steps": [

]
},
{
"file_colon_line": "features/step_definitions/json_parser_steps.rb:14",
"flags": "",
"source": "^the following JSON is parsed:$",
"flags": "",
"file_colon_line": "features/step_definitions/json_parser_steps.rb:14",
"steps": [
{
"name": "the following JSON is parsed:",
"args": [

],
"name": "the following JSON is parsed:"
]
}
]
},
{
"file_colon_line": "features/step_definitions/json_parser_steps.rb:18",
"flags": "",
"source": "^the outputted text should be:$",
"flags": "",
"file_colon_line": "features/step_definitions/json_parser_steps.rb:18",
"steps": [
{
"name": "the outputted text should be:",
"args": [

],
"name": "the outputted text should be:"
]
}
]
},
{
"file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:50",
"flags": "",
"source": "^I have Cucumber's source code next to Gherkin's$",
"flags": "",
"file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:50",
"steps": [
{
"name": "I have Cucumber's source code next to Gherkin's",
"args": [

],
"name": "I have Cucumber's source code next to Gherkin's"
]
}
]
},
{
"file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:55",
"flags": "",
"source": "^I find all of the \\.feature files$",
"flags": "",
"file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:55",
"steps": [
{
"name": "I find all of the .feature files",
"args": [

],
"name": "I find all of the .feature files"
]
}
]
},
{
"file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:59",
"flags": "",
"source": "^I send each prettified original through the \"([^\"]*)\" machinery$",
"flags": "",
"file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:59",
"steps": [
{
"name": "I send each prettified original through the \"json\" machinery",
"args": [
{
"offset": 45,
"val": "json"
}
],
"name": "I send each prettified original through the \"json\" machinery"
]
},
{
"name": "I send each prettified original through the \"pretty\" machinery",
"args": [
{
"offset": 45,
"val": "pretty"
}
],
"name": "I send each prettified original through the \"pretty\" machinery"
]
}
]
},
{
"file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:83",
"flags": "",
"source": "^the machinery output should be identical to the prettified original$",
"flags": "",
"file_colon_line": "features/step_definitions/pretty_formatter_steps.rb:83",
"steps": [
{
"name": "the machinery output should be identical to the prettified original",
"args": [

],
"name": "the machinery output should be identical to the prettified original"
]
}
]
}
Expand Down
4 changes: 4 additions & 0 deletions java/src/main/java/gherkin/TagExpression.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public Map<String, Integer> limits() {
return limits;
}

public boolean isEmpty() {
return and.isEmpty();
}

private void add(String[] tags) {
Or or = new Or();
for (String tag : tags) {
Expand Down
32 changes: 21 additions & 11 deletions java/src/main/java/gherkin/formatter/JSONFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public class JSONFormatter implements Reporter, Formatter {
private String uri;

private enum Phase {step, match, result, embedding, output};

/**
* In order to handle steps being added all at once, this method determines allows methods to
* opperator correctly if
*
* opperator correctly if
*
* step
* match
* result
Expand All @@ -40,9 +40,9 @@ private enum Phase {step, match, result, embedding, output};
* result
* embedding
* output
*
* or if
*
*
* or if
*
* step
* step
* match
Expand All @@ -53,9 +53,9 @@ private enum Phase {step, match, result, embedding, output};
* result
* embedding
* output
*
*
* is called
*
*
* @return the correct step for the current operation based on past method calls to the formatter interface
*/
private Map getCurrentStep(Phase phase){
Expand All @@ -76,8 +76,8 @@ private Map getCurrentStep(Phase phase){
}
return lastWithValue;
}


public JSONFormatter(Appendable out) {
this.out = new NiceAppendable(out);
}
Expand Down Expand Up @@ -164,6 +164,16 @@ private void addHook(final Match match, final Result result, String hook) {
hooks.add(hookMap);
}

public void appendDuration(final int timestamp) {
final Map result = (Map) getCurrentStep(Phase.result).get("result");
// check to make sure result exists (scenario outlines do not have results yet)
if (result != null) {
//convert to nanoseconds
final long nanos = timestamp * 1000000000L;
result.put("duration", nanos);
}
}

@Override
public void eof() {
}
Expand Down Expand Up @@ -238,4 +248,4 @@ private List<String> getOutput() {
protected Gson gson() {
return new GsonBuilder().create();
}
}
}
Loading

0 comments on commit 8871df0

Please sign in to comment.