Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

Commit b5bd31a

Browse files
Tim Perryjbpros
Tim Perry
authored andcommitted
Make feature id in JSON output replace all spaces (close 127)
1 parent 4b24a82 commit b5bd31a

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

features/json_formatter.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ Feature: JSON Formatter
496496
"""
497497
[
498498
{
499-
"id": "one-passes one fails",
499+
"id": "one-passes-one-fails",
500500
"name": "one passes one fails",
501501
"description": "",
502502
"line": 1,
@@ -505,7 +505,7 @@ Feature: JSON Formatter
505505
"elements": [
506506
{
507507
"name": "This one passes",
508-
"id": "one-passes one fails;this-one-passes",
508+
"id": "one-passes-one-fails;this-one-passes",
509509
"line": 3,
510510
"keyword": "Scenario",
511511
"description": "",
@@ -526,7 +526,7 @@ Feature: JSON Formatter
526526
},
527527
{
528528
"name": "This one fails",
529-
"id": "one-passes one fails;this-one-fails",
529+
"id": "one-passes-one-fails;this-one-fails",
530530
"line": 5,
531531
"keyword": "Scenario",
532532
"description": "",

lib/cucumber/listener/json_formatter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var JsonFormatter = function(options) {
6565

6666
self.handleBeforeFeatureEvent = function handleBeforeFeatureEvent(event, callback) {
6767
var feature = event.getPayloadItem('feature');
68-
currentFeatureId = feature.getName().replace(' ', '-'); // FIXME: wrong abstraction level, this should be encapsulated "somewhere"
68+
currentFeatureId = feature.getName().replace(/ /g, '-'); // FIXME: wrong abstraction level, this should be encapsulated "somewhere"
6969

7070
var featureProperties = {
7171
id: currentFeatureId,

spec/cucumber/listener/json_formatter_spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe("Cucumber.Listener.JsonFormatterWrapper", function () {
2525
beforeEach(function () {
2626
feature = createSpyWithStubs("feature", {
2727
getKeyword: 'Feature',
28-
getName: 'A Name',
28+
getName: 'A Feature Name',
2929
getDescription: 'A Description',
3030
getLine: 3,
3131
getUri: undefined,
@@ -39,8 +39,8 @@ describe("Cucumber.Listener.JsonFormatterWrapper", function () {
3939
listener.handleBeforeFeatureEvent(event, callback);
4040
expect(formatter.uri).toHaveBeenCalledWith(undefined);
4141
expect(formatter.feature).toHaveBeenCalledWith({
42-
id: 'A-Name',
43-
name: 'A Name',
42+
id: 'A-Feature-Name',
43+
name: 'A Feature Name',
4444
description: 'A Description',
4545
line: 3,
4646
keyword: 'Feature'

0 commit comments

Comments
 (0)