Skip to content

Commit

Permalink
fix use of gherkin dependency to not rely on removed field (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
charlierudolph committed Mar 20, 2017
1 parent 44667d9 commit 45c99c6
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 44 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ cache:
- $HOME/node_modules

deploy:
api_key: "$NPM_AUTH_TOKEN"
email: "charles.w.rudolph@gmail.com"
on:
branch: master
node: "6"
provider: script
script: scripts/deploy.sh
tags: true
provider: npm
skip_cleanup: true

language: node_js
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/ast/feature.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Feature(data, scenarios) {
function Feature(data, uri, scenarios) {
var Cucumber = require('../../cucumber');
var Gherkin = require('gherkin');
var _ = require('lodash');
Expand Down Expand Up @@ -51,7 +51,7 @@ function Feature(data, scenarios) {
},

getUri: function getUri() {
return data.uri;
return uri;
},

getLine: function getLine() {
Expand Down
8 changes: 2 additions & 6 deletions lib/cucumber/ast/scenario.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Scenario(data) {
function Scenario(data, uri) {
var Cucumber = require('../../cucumber');
var _ = require('lodash');
var feature, steps, tags = [];
Expand All @@ -25,11 +25,7 @@ function Scenario(data) {
},

getUri: function getUri() {
return _.first(self.getUris());
},

getUris: function getUris() {
return _.map(data.locations, 'path');
return uri;
},

getLine: function getLine() {
Expand Down
6 changes: 1 addition & 5 deletions lib/cucumber/ast/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ function Step(data) {
},

getUri: function getUri() {
return _.first(self.getUris());
},

getUris: function getUris() {
return _.map(data.locations, 'path');
return self.getScenario().getUri();
},

getPreviousStep: function getPreviousStep() {
Expand Down
8 changes: 3 additions & 5 deletions lib/cucumber/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@ function Parser(featureSources, astFilter) {
throw e;
}

var pickles = compiler.compile(gherkinDocument, uri);
var pickles = compiler.compile(gherkinDocument);
var scenarios = [];
pickles.forEach(function (pickleData) {
var scenario = Cucumber.Ast.Scenario(pickleData);
var scenario = Cucumber.Ast.Scenario(pickleData, uri);
if (astFilter.isElementEnrolled(scenario)) {
scenarios.push(scenario);
}
});

if (scenarios.length > 0) {
var featureData = gherkinDocument.feature;
featureData.uri = uri;
features.push(Cucumber.Ast.Feature(featureData, scenarios));
features.push(Cucumber.Ast.Feature(gherkinDocument.feature, uri, scenarios));
}
});

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"commander": "^2.9.0",
"duration": "^0.2.0",
"figures": "1.7.0",
"gherkin": "^4.0.0",
"gherkin": "^4.1.0",
"glob": "^7.0.0",
"is-generator": "^1.0.2",
"lodash": "^4.0.0",
Expand All @@ -127,7 +127,7 @@
"ansi_up": "^1.3.0",
"async": "^1.5.0",
"browserify": "^13.0.0",
"coffee-script": "^1.10.0",
"coffee-script": "^1.12.4",
"connect": "^3.4.0",
"exorcist": "^0.4.0",
"fs-extra": "^0.26.0",
Expand Down
19 changes: 9 additions & 10 deletions spec/cucumber/ast/feature_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ describe("Cucumber.Ast.Feature", function () {
tags: [
{tag1: 'data'},
{tag2: 'data'}
],
uri: 'uri'
]
};

scenario1 = createSpyWithStubs('scenario 1', {setFeature: null});
Expand All @@ -26,7 +25,7 @@ describe("Cucumber.Ast.Feature", function () {
tag2 = createSpy('tag 2');
spyOn(Cucumber.Ast, 'Tag').and.returnValues(tag1, tag2);

feature = Cucumber.Ast.Feature(featureData, scenarios);
feature = Cucumber.Ast.Feature(featureData, 'uri', scenarios);
});

describe("constructor", function () {
Expand All @@ -46,7 +45,7 @@ describe("Cucumber.Ast.Feature", function () {
' Scenario: Bar\n' +
' Then b\n';
var gherkinDocument = new Gherkin.Parser().parse(source);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, []);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, 'uri', []);
});

it('returns the keyword', function() {
Expand All @@ -61,7 +60,7 @@ describe("Cucumber.Ast.Feature", function () {
' Scenario: Bar\n' +
' Then b\n';
var gherkinDocument = new Gherkin.Parser().parse(source);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, []);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, 'uri', []);
});

it('returns the keyword', function() {
Expand All @@ -79,7 +78,7 @@ describe("Cucumber.Ast.Feature", function () {
' | what |\n' +
' | b |';
var gherkinDocument = new Gherkin.Parser().parse(source);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, []);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, 'uri', []);
});

it('returns the keyword', function() {
Expand All @@ -99,7 +98,7 @@ describe("Cucumber.Ast.Feature", function () {
'\n' +
' Then b\n';
var gherkinDocument = new Gherkin.Parser().parse(source);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, []);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, 'uri', []);
});

it('returns the keyword', function() {
Expand All @@ -115,7 +114,7 @@ describe("Cucumber.Ast.Feature", function () {
' Scenario: Bar\n' +
' Then b\n';
var gherkinDocument = new Gherkin.Parser().parse(source);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, []);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, 'uri', []);
});

it('returns the keyword', function() {
Expand All @@ -138,7 +137,7 @@ describe("Cucumber.Ast.Feature", function () {
' | what |\n' +
' | b |';
var gherkinDocument = new Gherkin.Parser().parse(source);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, []);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, 'uri', []);
});

it('returns the keyword', function() {
Expand All @@ -157,7 +156,7 @@ describe("Cucumber.Ast.Feature", function () {
' | what |\n' +
' | b |';
var gherkinDocument = new Gherkin.Parser().parse(source);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, []);
feature = Cucumber.Ast.Feature(gherkinDocument.feature, 'uri', []);
});

it('returns the keyword', function() {
Expand Down
6 changes: 3 additions & 3 deletions spec/cucumber/ast/scenario_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe("Cucumber.Ast.Scenario", function () {

beforeEach(function () {
var scenarioData = {
locations: [{path: 'path', line: 1}, {line: 2}],
locations: [{line: 1}, {line: 2}],
name: 'name',
steps: [
{step1: 'data'},
Expand All @@ -26,7 +26,7 @@ describe("Cucumber.Ast.Scenario", function () {
tag2 = createSpy('tag 2');
spyOn(Cucumber.Ast, 'Tag').and.returnValues(tag1, tag2);

scenario = Cucumber.Ast.Scenario(scenarioData);
scenario = Cucumber.Ast.Scenario(scenarioData, 'uri');
});

describe("constructor", function () {
Expand Down Expand Up @@ -80,7 +80,7 @@ describe("Cucumber.Ast.Scenario", function () {

describe("getUri()", function () {
it("returns the URI on which the background starts", function () {
expect(scenario.getUri()).toEqual('path');
expect(scenario.getUri()).toEqual('uri');
});
});

Expand Down
16 changes: 8 additions & 8 deletions spec/cucumber/parser_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ describe("Cucumber.Parser", function () {
});

it("compiles the feature data", function () {
expect(gherkinCompiler.compile).toHaveBeenCalledWith(gherkinDocument1, 'first feature uri');
expect(gherkinCompiler.compile).toHaveBeenCalledWith(gherkinDocument2, 'second feature uri');
expect(gherkinCompiler.compile).toHaveBeenCalledWith(gherkinDocument1);
expect(gherkinCompiler.compile).toHaveBeenCalledWith(gherkinDocument2);
});

it("creates the scenarios", function () {
expect(Cucumber.Ast.Scenario).toHaveBeenCalledWith(pickle1Data);
expect(Cucumber.Ast.Scenario).toHaveBeenCalledWith(pickle2Data);
expect(Cucumber.Ast.Scenario).toHaveBeenCalledWith(pickle3Data);
expect(Cucumber.Ast.Scenario).toHaveBeenCalledWith(pickle4Data);
expect(Cucumber.Ast.Scenario).toHaveBeenCalledWith(pickle1Data, 'first feature uri');
expect(Cucumber.Ast.Scenario).toHaveBeenCalledWith(pickle2Data, 'first feature uri');
expect(Cucumber.Ast.Scenario).toHaveBeenCalledWith(pickle3Data, 'second feature uri');
expect(Cucumber.Ast.Scenario).toHaveBeenCalledWith(pickle4Data, 'second feature uri');
});

it("checks if each scenario should be enrolled", function () {
Expand All @@ -73,8 +73,8 @@ describe("Cucumber.Parser", function () {
});

it("creates the features", function () {
expect(Cucumber.Ast.Feature).toHaveBeenCalledWith({feature1: 'data', uri: 'first feature uri'}, [scenario1, scenario2]);
expect(Cucumber.Ast.Feature).toHaveBeenCalledWith({feature2: 'data', uri: 'second feature uri'}, [scenario3]);
expect(Cucumber.Ast.Feature).toHaveBeenCalledWith({feature1: 'data'}, 'first feature uri', [scenario1, scenario2]);
expect(Cucumber.Ast.Feature).toHaveBeenCalledWith({feature2: 'data'}, 'second feature uri', [scenario3]);
});

it("returns the features", function () {
Expand Down

0 comments on commit 45c99c6

Please sign in to comment.