Skip to content

Commit

Permalink
Partial fix for #197.
Browse files Browse the repository at this point in the history
For now JsonPretty is an empty subclass of Json.  It doesn't produce prettyfied json, but at least id doesn't throws exceptions
  • Loading branch information
os97673 committed Mar 16, 2013
1 parent cc4783f commit 73fe183
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 7 deletions.
89 changes: 86 additions & 3 deletions features/json_formatter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,96 @@ Feature: JSON output formatter
"""

@wip-jruby
Scenario: one feature, one passing scenario, one failing scenario with prettyfied json
When I run cucumber "--format json_pretty features/one_passing_one_failing.feature"
Then it should fail with JSON:
"""
[
{
"uri": "features/one_passing_one_failing.feature",
"keyword": "Feature",
"id": "one-passing-scenario,-one-failing-scenario",
"name": "One passing scenario, one failing scenario",
"line": 2,
"description": "",
"tags": [
{
"name": "@a",
"line": 1
}
],
"elements": [
{
"keyword": "Scenario",
"id": "one-passing-scenario,-one-failing-scenario;passing",
"name": "Passing",
"line": 5,
"description": "",
"tags": [
{
"name": "@b",
"line": 4
}
],
"type": "scenario",
"steps": [
{
"keyword": "Given ",
"name": "a passing step",
"line": 6,
"match": {
"location": "features/step_definitions/steps.rb:1"
},
"result": {
"status": "passed",
"duration": 1
}
}
]
},
{
"keyword": "Scenario",
"id": "one-passing-scenario,-one-failing-scenario;failing",
"name": "Failing",
"line": 9,
"description": "",
"tags": [
{
"name": "@c",
"line": 8
}
],
"type": "scenario",
"steps": [
{
"keyword": "Given ",
"name": "a failing step",
"line": 10,
"match": {
"location": "features/step_definitions/steps.rb:5"
},
"result": {
"status": "failed",
"error_message": " (RuntimeError)\n./features/step_definitions/steps.rb:6:in `/a failing step/'\nfeatures/one_passing_one_failing.feature:10:in `Given a failing step'",
"duration": 1
}
}
]
}
]
}
]
"""

@wip-jruby
Scenario: DocString
Given a file named "features/doc_string.feature" with:
"""
Feature: A DocString feature
Scenario:
Scenario:
Then I should fail with
\"\"\"
a string
Expand Down Expand Up @@ -186,8 +269,8 @@ Feature: JSON output formatter
"name": "I should fail with",
"line": 4,
"doc_string": {
"content_type": "",
"value": "a string",
"content_type": "",
"value": "a string",
"line": 5
},
"match": {
Expand Down
4 changes: 0 additions & 4 deletions lib/cucumber/formatter/json_pretty.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
require 'multi_json'
require 'cucumber/formatter/json'

module Cucumber
module Formatter
# The formatter used for <tt>--format json_pretty</tt>
class JsonPretty < Json
def after_features(features)
@io.write(MultiJson.dump(@obj, :pretty => true))
end
end
end
end
Expand Down

0 comments on commit 73fe183

Please sign in to comment.