Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Store URI on AST elements

  • Loading branch information...
commit 35c4d25c7d9745e3c9471b27655030b230846f5c 1 parent 3057098
@jbpros jbpros authored
View
6 lib/cucumber/ast/background.js
@@ -1,4 +1,4 @@
-var Background = function(keyword, name, description, line) {
+var Background = function(keyword, name, description, uri, line) {
var Cucumber = require('../../cucumber');
var steps = Cucumber.Type.Collection();
@@ -16,6 +16,10 @@ var Background = function(keyword, name, description, line) {
return description;
},
+ getUri: function getUri() {
+ return uri;
+ },
+
getLine: function getLine() {
return line;
},
View
2  lib/cucumber/ast/data_table/row.js
@@ -1,4 +1,4 @@
-var Row = function(cells, line) {
+var Row = function(cells, uri, line) {
var Cucumber = require('../../../cucumber');
self = {
View
6 lib/cucumber/ast/doc_string.js
@@ -1,4 +1,4 @@
-var DocString = function(contentType, contents, line) {
+var DocString = function(contentType, contents, uri, line) {
var self = {
getContents: function getContents() {
return contents;
@@ -8,6 +8,10 @@ var DocString = function(contentType, contents, line) {
return contentType;
},
+ getUri: function getUri() {
+ return uri;
+ },
+
getLine: function getLine() {
return line;
}
View
6 lib/cucumber/ast/feature.js
@@ -1,4 +1,4 @@
-var Feature = function(keyword, name, description, line) {
+var Feature = function(keyword, name, description, uri, line) {
var Cucumber = require('../../cucumber');
var background;
@@ -18,6 +18,10 @@ var Feature = function(keyword, name, description, line) {
return description;
},
+ getUri: function getUri() {
+ return uri;
+ },
+
getLine: function getLine() {
return line;
},
View
6 lib/cucumber/ast/scenario.js
@@ -1,4 +1,4 @@
-var Scenario = function(keyword, name, description, line) {
+var Scenario = function(keyword, name, description, uri, line) {
var Cucumber = require('../../cucumber');
var background;
@@ -22,6 +22,10 @@ var Scenario = function(keyword, name, description, line) {
return description;
},
+ getUri: function getUri() {
+ return uri;
+ },
+
getLine: function getLine() {
return line;
},
View
6 lib/cucumber/ast/step.js
@@ -1,4 +1,4 @@
-var Step = function(keyword, name, line) {
+var Step = function(keyword, name, uri, line) {
var Cucumber = require('../../cucumber');
var docString, dataTable, previousStep;
@@ -15,6 +15,10 @@ var Step = function(keyword, name, line) {
return name;
},
+ getUri: function getUri() {
+ return uri;
+ },
+
getLine: function getLine() {
return line;
},
View
12 lib/cucumber/ast/tag.js
@@ -1,11 +1,19 @@
-var Tag = function(name, line) {
+var Tag = function(name, uri, line) {
var Cucumber = require('../../cucumber');
var self = {
getName: function getName() {
return name;
+ },
+
+ getUri: function getUri() {
+ return uri;
+ },
+
+ getLine: function getLine() {
+ return line;
}
};
return self;
};
-module.exports = Tag;
+module.exports = Tag;
View
43 lib/cucumber/parser.js
@@ -4,18 +4,29 @@ var Parser = function(featureSources, astFilter) {
var features = Cucumber.Ast.Features();
var astAssembler = Cucumber.Ast.Assembler(features, astFilter);
+ var currentSourceUri;
var self = {
parse: function parse() {
var Lexer = Gherkin.Lexer('en');
var lexer = new Lexer(self.getEventHandlers());
for (i in featureSources) {
- var featureSource = featureSources[i][Parser.FEATURE_NAME_SOURCE_PAIR_SOURCE_INDEX];
+ var currentSourceUri = featureSources[i][Parser.FEATURE_NAME_SOURCE_PAIR_URI_INDEX];
+ var featureSource = featureSources[i][Parser.FEATURE_NAME_SOURCE_PAIR_SOURCE_INDEX];
+ self.setCurrentSourceUri(currentSourceUri);
lexer.scan(featureSource);
}
return features;
},
+ setCurrentSourceUri: function setCurrentSourceUri(uri) {
+ currentSourceUri = uri;
+ },
+
+ getCurrentSourceUri: function getCurrentSourceUri() {
+ return currentSourceUri;
+ },
+
getEventHandlers: function getEventHandlers() {
return {
background: self.handleBackground,
@@ -30,46 +41,54 @@ var Parser = function(featureSources, astFilter) {
};
},
- handleTag: function handleTag(tag, line) {
- var tag = Cucumber.Ast.Tag(tag, line);
- astAssembler.insertTag(tag);
- },
-
handleBackground: function handleBackground(keyword, name, description, line) {
- var background = Cucumber.Ast.Background(keyword, name, description, line);
+ var uri = self.getCurrentSourceUri();
+ var background = Cucumber.Ast.Background(keyword, name, description, uri, line);
astAssembler.insertBackground(background);
},
handleComment: function handleComment() {},
handleDocString: function handleDocString(contentType, string, line) {
- var docString = Cucumber.Ast.DocString(contentType, string, line);
+ var uri = self.getCurrentSourceUri();
+ var docString = Cucumber.Ast.DocString(contentType, string, uri, line);
astAssembler.insertDocString(docString);
},
handleEof: function handleEof() {},
handleFeature: function handleFeature(keyword, name, description, line) {
- var feature = Cucumber.Ast.Feature(keyword, name, description, line);
+ var uri = self.getCurrentSourceUri();
+ var feature = Cucumber.Ast.Feature(keyword, name, description, uri, line);
astAssembler.insertFeature(feature);
},
handleDataTableRow: function handleDataTableRow(cells, line) {
- var dataTableRow = Cucumber.Ast.DataTable.Row(cells, line);
+ var uri = self.getCurrentSourceUri();
+ var dataTableRow = Cucumber.Ast.DataTable.Row(cells, uri, line);
astAssembler.insertDataTableRow(dataTableRow);
},
handleScenario: function handleScenario(keyword, name, description, line) {
- var scenario = Cucumber.Ast.Scenario(keyword, name, description, line);
+ var uri = self.getCurrentSourceUri();
+ var scenario = Cucumber.Ast.Scenario(keyword, name, description, uri, line);
astAssembler.insertScenario(scenario);
},
handleStep: function handleStep(keyword, name, line) {
- var step = Cucumber.Ast.Step(keyword, name, line);
+ var uri = self.getCurrentSourceUri();
+ var step = Cucumber.Ast.Step(keyword, name, uri, line);
astAssembler.insertStep(step);
+ },
+
+ handleTag: function handleTag(tag, line) {
+ var uri = self.getCurrentSourceUri();
+ var tag = Cucumber.Ast.Tag(tag, uri, line);
+ astAssembler.insertTag(tag);
}
};
return self;
};
+Parser.FEATURE_NAME_SOURCE_PAIR_URI_INDEX = 0;
Parser.FEATURE_NAME_SOURCE_PAIR_SOURCE_INDEX = 1;
module.exports = Parser;
View
11 spec/cucumber/ast/background_spec.js
@@ -3,19 +3,20 @@ require('../../support/spec_helper');
describe("Cucumber.Ast.Background", function() {
var Cucumber = requireLib('cucumber');
var steps;
- var background, keyword, name, description, line, lastStep;
+ var background, keyword, name, description, uri, line, lastStep;
beforeEach(function() {
keyword = createSpy("background keyword");
name = createSpy("background name");
description = createSpy("background description");
+ uri = createSpy("uri");
line = createSpy("starting background line number");
lastStep = createSpy("Last step");
steps = createSpy("Step collection");
spyOnStub(steps, 'add');
spyOnStub(steps, 'getLast').andReturn(lastStep);
spyOn(Cucumber.Type, 'Collection').andReturn(steps);
- background = Cucumber.Ast.Background(keyword, name, description, line);
+ background = Cucumber.Ast.Background(keyword, name, description, uri, line);
});
describe("constructor", function() {
@@ -42,6 +43,12 @@ describe("Cucumber.Ast.Background", function() {
});
});
+ describe("getUri()", function() {
+ it("returns the URI on which the background starts", function() {
+ expect(background.getUri()).toBe(uri);
+ });
+ });
+
describe("getLine()", function() {
it("returns the line on which the background starts", function() {
expect(background.getLine()).toBe(line);
View
5 spec/cucumber/ast/data_table/row_spec.js
@@ -3,12 +3,13 @@ require('../../../support/spec_helper');
describe("Cucumber.Ast.Feature", function() {
var Cucumber = requireLib('cucumber');
- var row, cells, line;
+ var row, cells, uri, line;
beforeEach(function() {
cells = createSpy("cells");
+ uri = createSpy("uri");
line = createSpy("line");
- row = Cucumber.Ast.DataTable.Row(cells);
+ row = Cucumber.Ast.DataTable.Row(cells, uri, line);
});
describe("raw()", function() {
View
15 spec/cucumber/ast/doc_string_spec.js
@@ -2,13 +2,14 @@ require('../../support/spec_helper');
describe("Cucumber.Ast.DocString", function() {
var Cucumber = requireLib('cucumber');
- var docString, contents, line;
+ var docString, contents, uri, line;
beforeEach(function() {
contentType = createSpy("content type");
- contents = createSpy("DocString contents");
- line = createSpy("DocString line number");
- docString = Cucumber.Ast.DocString(contentType, contents, line);
+ contents = createSpy("contents");
+ uri = createSpy("uri");
+ line = createSpy("line number");
+ docString = Cucumber.Ast.DocString(contentType, contents, uri, line);
});
describe("getContents()", function() {
@@ -23,6 +24,12 @@ describe("Cucumber.Ast.DocString", function() {
});
});
+ describe("getUri()", function() {
+ it("returns the URI on which the background starts", function() {
+ expect(docString.getUri()).toBe(uri);
+ });
+ });
+
describe("getLine()", function() {
it("returns the line on which the DocString starts", function() {
expect(docString.getLine()).toBe(line);
View
19 spec/cucumber/ast/feature_spec.js
@@ -3,7 +3,7 @@ require('../../support/spec_helper');
describe("Cucumber.Ast.Feature", function() {
var Cucumber = requireLib('cucumber');
var scenarioCollection, lastScenario;
- var feature, keyword, name, line;
+ var feature, keyword, name, uri, line;
beforeEach(function() {
lastScenario = createSpy("Last scenario");
@@ -12,11 +12,12 @@ describe("Cucumber.Ast.Feature", function() {
spyOnStub(scenarioCollection, 'getLast').andReturn(lastScenario);
spyOnStub(scenarioCollection, 'forEach');
spyOn(Cucumber.Type, 'Collection').andReturn(scenarioCollection);
- keyword = createSpy("Feature keyword");
- name = createSpy("Feature name");
- description = createSpy("Feature description");
- line = createSpy("Feature line number");
- feature = Cucumber.Ast.Feature(keyword, name, description, line);
+ keyword = createSpy("keyword");
+ name = createSpy("name");
+ description = createSpy("description");
+ uri = createSpy("uri");
+ line = createSpy("line number");
+ feature = Cucumber.Ast.Feature(keyword, name, description, uri, line);
});
describe("constructor", function() {
@@ -43,6 +44,12 @@ describe("Cucumber.Ast.Feature", function() {
});
});
+ describe("getUri()", function() {
+ it("returns the URI on which the background starts", function() {
+ expect(feature.getUri()).toBe(uri);
+ });
+ });
+
describe("getLine()", function() {
it("returns the line number on which the feature starts", function() {
expect(feature.getLine()).toBe(line);
View
11 spec/cucumber/ast/scenario_spec.js
@@ -3,19 +3,20 @@ require('../../support/spec_helper');
describe("Cucumber.Ast.Scenario", function() {
var Cucumber = requireLib('cucumber');
var steps;
- var scenario, keyword, name, description, line, lastStep;
+ var scenario, keyword, name, description, uri, line, lastStep;
beforeEach(function() {
keyword = createSpy("scenario keyword");
name = createSpy("scenario name");
description = createSpy("scenario description");
+ uri = createSpy("uri");
line = createSpy("starting scenario line number");
lastStep = createSpy("last step");
steps = createSpy("step collection");
spyOnStub(steps, 'add');
spyOnStub(steps, 'getLast').andReturn(lastStep);
spyOn(Cucumber.Type, 'Collection').andReturn(steps);
- scenario = Cucumber.Ast.Scenario(keyword, name, description, line);
+ scenario = Cucumber.Ast.Scenario(keyword, name, description, uri, line);
});
describe("constructor", function() {
@@ -42,6 +43,12 @@ describe("Cucumber.Ast.Scenario", function() {
});
});
+ describe("getUri()", function() {
+ it("returns the URI on which the background starts", function() {
+ expect(scenario.getUri()).toBe(uri);
+ });
+ });
+
describe("getLine()", function() {
it("returns the line on which the scenario starts", function() {
expect(scenario.getLine()).toBe(line);
View
17 spec/cucumber/ast/step_spec.js
@@ -2,13 +2,14 @@ require('../../support/spec_helper');
describe("Cucumber.Ast.Step", function() {
var Cucumber = requireLib('cucumber');
- var step, keyword, name, line;
+ var step, keyword, name, uri, line;
beforeEach(function() {
- name = createSpy("Step name");
- keyword = createSpy("Step keyword");
- line = createSpy("Step line");
- step = Cucumber.Ast.Step(keyword, name, line);
+ name = createSpy("name");
+ keyword = createSpy("keyword");
+ uri = createSpy("uri");
+ line = createSpy("line");
+ step = Cucumber.Ast.Step(keyword, name, uri, line);
});
describe("getKeyword()", function() {
@@ -23,6 +24,12 @@ describe("Cucumber.Ast.Step", function() {
});
});
+ describe("getUri()", function() {
+ it("returns the URI on which the background starts", function() {
+ expect(step.getUri()).toBe(uri);
+ });
+ });
+
describe("getLine()", function() {
it("returns the line number on which the step lies", function() {
expect(step.getLine()).toBe(line);
View
23 spec/cucumber/ast/tag_spec.js
@@ -3,12 +3,13 @@ require('../../support/spec_helper');
describe("Cucumber.Ast.Tag", function() {
var Cucumber = requireLib('cucumber');
- var tag, name, line;
+ var tag, name, uri, line;
beforeEach(function() {
- name = createSpy("tag name");
- line = createSpy("tag line");
- tag = Cucumber.Ast.Tag(name, line);
+ name = createSpy("name");
+ uri = createSpy("uri");
+ line = createSpy("line");
+ tag = Cucumber.Ast.Tag(name, uri, line);
});
describe("getName()", function() {
@@ -16,4 +17,16 @@ describe("Cucumber.Ast.Tag", function() {
expect(tag.getName()).toBe(name);
});
});
-});
+
+ describe("getUri()", function() {
+ it("returns the URI on which the background starts", function() {
+ expect(tag.getUri()).toBe(uri);
+ });
+ });
+
+ describe("getLine()", function() {
+ it("returns the line on which the DocString starts", function() {
+ expect(tag.getLine()).toBe(line);
+ });
+ });
+});
View
213 spec/cucumber/parser_spec.js
@@ -1,11 +1,11 @@
require('../support/spec_helper');
-describe("Cucumber.Parser", function() {
+describe("Cucumber.Parser", function () {
var Cucumber = requireLib('cucumber');
var parser, featureSources;
var features, astFilter, astAssembler;
- beforeEach(function() {
+ beforeEach(function () {
features = createSpy("Root 'features' AST element");
astFilter = createSpy("AST filter");
featureSources = [
@@ -18,288 +18,357 @@ describe("Cucumber.Parser", function() {
parser = Cucumber.Parser(featureSources, astFilter);
});
- describe("constructor", function() {
- it("creates a new AST features element", function() {
+ describe("constructor", function () {
+ it("creates a new AST features element", function () {
expect(Cucumber.Ast.Features).toHaveBeenCalled();
});
- it("instantiates an AST assembler", function() {
+ it("instantiates an AST assembler", function () {
expect(Cucumber.Ast.Assembler).toHaveBeenCalledWith(features, astFilter);
});
});
- describe("parse()", function() {
+ describe("parse()", function () {
var Gherkin = require('gherkin');
var gherkinLexerConstructor, gherkinLexer;
var eventHandlers;
- beforeEach(function() {
+ beforeEach(function () {
gherkinLexer = createSpyWithStubs("Gherkin lexer instance", {scan: null});
gherkinLexerConstructor = createSpy("Gherkin lexer module").andReturn(gherkinLexer);
eventHandlers = createSpy("Parser event handlers");
spyOn(Gherkin, 'Lexer').andReturn(gherkinLexerConstructor);
spyOn(parser, 'getEventHandlers').andReturn(eventHandlers);
+ spyOn(parser, 'setCurrentSourceUri');
});
- it("loads the gherkin lexer module for English", function() {
+ it("loads the gherkin lexer module for English", function () {
parser.parse();
expect(Gherkin.Lexer).toHaveBeenCalledWith('en');
});
- it("gets the parse event handlers", function() {
+ it("gets the parse event handlers", function () {
parser.parse();
expect(parser.getEventHandlers).toHaveBeenCalled();
});
- it("creates a gherkin lexer", function() {
+ it("creates a gherkin lexer", function () {
parser.parse();
expect(gherkinLexerConstructor).toHaveBeenCalledWith(eventHandlers);
});
- it("asks the lexer to scan each feature source", function() {
+ it("sets the uri of each feature source", function () {
+ parser.parse();
+ expect(parser.setCurrentSourceUri).toHaveBeenCalledWith(featureSources[0][0]);
+ expect(parser.setCurrentSourceUri).toHaveBeenCalledWith(featureSources[1][0]);
+ });
+
+ it("asks the lexer to scan each feature source", function () {
parser.parse();
expect(gherkinLexer.scan).toHaveBeenCalledWith(featureSources[0][1]);
expect(gherkinLexer.scan).toHaveBeenCalledWith(featureSources[1][1]);
});
- it("returns the features root element", function() {
+ it("returns the features root element", function () {
expect(parser.parse()).toBe(features);
});
});
- describe("getEventHandlers()", function() {
+ describe("getCurrentSourceUri() [setCurrentSourceUri()]", function () {
+ var uri;
+
+ beforeEach(function () {
+ uri = createSpy("uri");
+ });
+
+ it("returns the stored current source URI", function () {
+ parser.setCurrentSourceUri(uri);
+ expect(parser.getCurrentSourceUri()).toBe(uri);
+ });
+ });
+
+ describe("getEventHandlers()", function () {
var eventHandlers;
- it("provides a 'feature' handler", function() {
+ it("provides a 'feature' handler", function () {
spyOn(parser, 'handleFeature');
eventHandlers = parser.getEventHandlers();
expect(eventHandlers['feature']).toBe(parser.handleFeature);
});
- it("provides a 'background' handler", function() {
+ it("provides a 'background' handler", function () {
spyOn(parser, 'handleBackground');
eventHandlers = parser.getEventHandlers();
expect(eventHandlers['background']).toBe(parser.handleBackground);
});
- it("provides a 'scenario' handler", function() {
+ it("provides a 'scenario' handler", function () {
spyOn(parser, 'handleScenario');
eventHandlers = parser.getEventHandlers();
expect(eventHandlers['scenario']).toBe(parser.handleScenario);
});
- it("provides a 'step' handler", function() {
+ it("provides a 'step' handler", function () {
spyOn(parser, 'handleStep');
eventHandlers = parser.getEventHandlers();
expect(eventHandlers['step']).toBe(parser.handleStep);
});
- it("provides a 'doc_string' handler", function() {
+ it("provides a 'doc_string' handler", function () {
spyOn(parser, 'handleDocString');
eventHandlers = parser.getEventHandlers();
expect(eventHandlers['doc_string']).toBe(parser.handleDocString);
});
- it("provides a 'eof' handler", function() {
+ it("provides a 'eof' handler", function () {
spyOn(parser, 'handleEof');
eventHandlers = parser.getEventHandlers();
expect(eventHandlers['eof']).toBe(parser.handleEof);
});
- it("provides a 'comment' handler", function() {
+ it("provides a 'comment' handler", function () {
spyOn(parser, 'handleComment');
eventHandlers = parser.getEventHandlers();
expect(eventHandlers['comment']).toBe(parser.handleComment);
});
- it("provides a 'row' handler", function() {
+ it("provides a 'row' handler", function () {
spyOn(parser, 'handleDataTableRow');
eventHandlers = parser.getEventHandlers();
expect(eventHandlers['row']).toBe(parser.handleDataTableRow);
});
- it("provides a 'tag' handler", function() {
+ it("provides a 'tag' handler", function () {
spyOn(parser, 'handleTag');
eventHandlers = parser.getEventHandlers();
expect(eventHandlers['tag']).toBe(parser.handleTag);
});
});
- describe("handleBackground()", function() {
+ describe("handleBackground()", function () {
var keyword, name, description, line;
var background;
- beforeEach(function() {
+ beforeEach(function () {
keyword = createSpy("'background' keyword");
name = createSpy("name of the background");
description = createSpy("description of the background");
+ uri = createSpy("uri");
line = createSpy("line number");
background = createSpyWithStubs("background AST element");
+ spyOn(parser, 'getCurrentSourceUri').andReturn(uri);
spyOn(Cucumber.Ast, 'Background').andReturn(background);
spyOnStub(astAssembler, 'insertBackground');
});
- it("creates a new background AST element", function() {
+ it("gets the current source URI", function () {
parser.handleBackground(keyword, name, description, line);
- expect(Cucumber.Ast.Background).toHaveBeenCalledWith(keyword, name, description, line);
+ expect(parser.getCurrentSourceUri).toHaveBeenCalled();
});
- it("tells the AST assembler to insert the background into the tree", function() {
+ it("creates a new background AST element", function () {
+ parser.handleBackground(keyword, name, description, line);
+ expect(Cucumber.Ast.Background).toHaveBeenCalledWith(keyword, name, description, uri, line);
+ });
+
+ it("tells the AST assembler to insert the background into the tree", function () {
parser.handleBackground(keyword, name, description, line);
expect(astAssembler.insertBackground).toHaveBeenCalledWith(background);
});
});
- describe("handleComment()", function() {
- it("exists but does nothing", function() {
+ describe("handleComment()", function () {
+ it("exists but does nothing", function () {
parser.handleComment();
});
});
- describe("handleDocString()", function() {
- var contentType, string, line;
+ describe("handleDocString()", function () {
+ var contentType, string, uri, line;
var docString;
- beforeEach(function() {
+ beforeEach(function () {
contentType = createSpy("DocString's content type");
string = createSpy("DocString's actual string");
+ uri = createSpy("uri");
line = createSpy("line number");
docString = createSpy("DocString AST element");
+ spyOn(parser, 'getCurrentSourceUri').andReturn(uri);
spyOn(Cucumber.Ast, 'DocString').andReturn(docString);
spyOnStub(astAssembler, 'insertDocString');
});
- it("creates a new DocString AST element", function() {
+ it("gets the current source URI", function () {
+ parser.handleDocString(contentType, string, line);
+ expect(parser.getCurrentSourceUri).toHaveBeenCalled();
+ });
+
+ it("creates a new DocString AST element", function () {
parser.handleDocString(contentType, string, line);
- expect(Cucumber.Ast.DocString).toHaveBeenCalledWith(contentType, string, line);
+ expect(Cucumber.Ast.DocString).toHaveBeenCalledWith(contentType, string, uri, line);
});
- it("tells the AST assembler to insert the DocString into the tree", function() {
+ it("tells the AST assembler to insert the DocString into the tree", function () {
parser.handleDocString(contentType, string, line);
expect(astAssembler.insertDocString).toHaveBeenCalledWith(docString);
});
});
- describe("handleEof()", function() {
- it("exists but does nothing", function() {
+ describe("handleEof()", function () {
+ it("exists but does nothing", function () {
parser.handleEof();
});
});
- describe("handleFeature()", function() {
- var keyword, name, description, line;
+ describe("handleFeature()", function () {
+ var keyword, name, description, uri, line;
var feature;
- beforeEach(function() {
+ beforeEach(function () {
keyword = createSpy("'feature' keyword");
name = createSpy("Name of the feature");
description = createSpy("Description of the feature");
+ uri = createSpy("uri");
line = createSpy("Line number");
feature = createSpyWithStubs("Feature AST element");
+ spyOn(parser, 'getCurrentSourceUri').andReturn(uri);
spyOn(Cucumber.Ast, 'Feature').andReturn(feature);
spyOnStub(astAssembler, 'insertFeature');
});
- it("creates a new feature AST element", function() {
+ it("gets the current source URI", function () {
parser.handleFeature(keyword, name, description, line);
- expect(Cucumber.Ast.Feature).toHaveBeenCalledWith(keyword, name, description, line);
+ expect(parser.getCurrentSourceUri).toHaveBeenCalled();
});
- it("tells the AST assembler to insert the feature into the tree", function() {
+ it("creates a new feature AST element", function () {
+ parser.handleFeature(keyword, name, description, line);
+ expect(Cucumber.Ast.Feature).toHaveBeenCalledWith(keyword, name, description, uri, line);
+ });
+
+ it("tells the AST assembler to insert the feature into the tree", function () {
parser.handleFeature(keyword, name, description, line);
expect(astAssembler.insertFeature).toHaveBeenCalledWith(feature);
});
});
- describe("handleDataTableRow()", function() {
- var cells, line;
+ describe("handleDataTableRow()", function () {
+ var cells, uri, line;
var dataTableRow;
- beforeEach(function() {
+ beforeEach(function () {
dataTableRow = createSpy("data table row");
cells = createSpy("data table cells");
+ uri = createSpy("uri");
line = createSpy("line");
+ spyOn(parser, 'getCurrentSourceUri').andReturn(uri);
spyOn(Cucumber.Ast.DataTable, 'Row').andReturn(dataTableRow);
spyOnStub(astAssembler, 'insertDataTableRow');
});
- it("creates a new data table row AST element", function() {
+ it("gets the current source URI", function () {
+ parser.handleDataTableRow(cells, line);
+ expect(parser.getCurrentSourceUri).toHaveBeenCalled();
+ });
+
+ it("creates a new data table row AST element", function () {
parser.handleDataTableRow(cells, line);
- expect(Cucumber.Ast.DataTable.Row).toHaveBeenCalledWith(cells, line);
+ expect(Cucumber.Ast.DataTable.Row).toHaveBeenCalledWith(cells, uri, line);
});
- it("tells the AST assembler to insert the data table row into the tree", function() {
+ it("tells the AST assembler to insert the data table row into the tree", function () {
parser.handleDataTableRow(cells, line);
expect(astAssembler.insertDataTableRow).toHaveBeenCalledWith(dataTableRow);
});
});
- describe("handleScenario()", function() {
- var keyword, name, description, line;
+ describe("handleScenario()", function () {
+ var keyword, name, description, uri, line;
var scenario;
- beforeEach(function() {
- keyword = createSpy("'scenario' keyword");
- name = createSpy("Name of the scenario");
- description = createSpy("Description of the scenario");
- line = createSpy("Line number");
- scenario = createSpyWithStubs("Scenario AST element");
+ beforeEach(function () {
+ keyword = createSpy("'scenario' keyword");
+ name = createSpy("Name of the scenario");
+ description = createSpy("Description of the scenario");
+ uri = createSpy("uri");
+ line = createSpy("Line number");
+ scenario = createSpyWithStubs("Scenario AST element");
+ spyOn(parser, 'getCurrentSourceUri').andReturn(uri);
spyOn(Cucumber.Ast, 'Scenario').andReturn(scenario);
spyOnStub(astAssembler, 'insertScenario');
});
- it("creates a new scenario AST element", function() {
+ it("gets the current source URI", function () {
+ parser.handleScenario(keyword, name, description, line);
+ expect(parser.getCurrentSourceUri).toHaveBeenCalled();
+ });
+
+ it("creates a new scenario AST element", function () {
parser.handleScenario(keyword, name, description, line);
- expect(Cucumber.Ast.Scenario).toHaveBeenCalledWith(keyword, name, description, line);
+ expect(Cucumber.Ast.Scenario).toHaveBeenCalledWith(keyword, name, description, uri, line);
});
- it("tells the AST assembler to insert the scenario into the tree", function() {
+ it("tells the AST assembler to insert the scenario into the tree", function () {
parser.handleScenario(keyword, name, description, line);
expect(astAssembler.insertScenario).toHaveBeenCalledWith(scenario);
});
});
- describe("handleStep()", function() {
- var keyword, name, line;
+ describe("handleStep()", function () {
+ var keyword, name, uri, line;
var step;
- beforeEach(function() {
+ beforeEach(function () {
keyword = createSpy("'step' keyword");
name = createSpy("name of the step");
+ uri = createSpy("uri");
line = createSpy("line number");
step = createSpy("step AST element");
+ spyOn(parser, 'getCurrentSourceUri').andReturn(uri);
spyOn(Cucumber.Ast, 'Step').andReturn(step);
spyOnStub(astAssembler, 'insertStep');
});
- it("creates a new step AST element", function() {
+ it("gets the current source URI", function () {
+ parser.handleStep(keyword, name, line);
+ expect(parser.getCurrentSourceUri).toHaveBeenCalled();
+ });
+
+ it("creates a new step AST element", function () {
parser.handleStep(keyword, name, line);
- expect(Cucumber.Ast.Step).toHaveBeenCalledWith(keyword, name, line);
+ expect(Cucumber.Ast.Step).toHaveBeenCalledWith(keyword, name, uri, line);
});
- it("tells the AST assembler to insert the step into the tree", function() {
+ it("tells the AST assembler to insert the step into the tree", function () {
parser.handleStep(keyword, name, line);
expect(astAssembler.insertStep).toHaveBeenCalledWith(step);
});
});
- describe("handleTag()", function() {
- var name, line;
+ describe("handleTag()", function () {
+ var name, uri, line;
- beforeEach(function() {
+ beforeEach(function () {
name = createSpy("tag name");
+ uri = createSpy("uri");
line = createSpy("line number");
tag = createSpy("tag AST element");
+ spyOn(parser, 'getCurrentSourceUri').andReturn(uri);
spyOn(Cucumber.Ast, 'Tag').andReturn(tag);
spyOnStub(astAssembler, 'insertTag');
});
- it("creates a new tag AST element", function() {
+ it("gets the current source URI", function () {
+ parser.handleTag(name, line);
+ expect(parser.getCurrentSourceUri).toHaveBeenCalled();
+ });
+
+ it("creates a new tag AST element", function () {
parser.handleTag(name, line);
- expect(Cucumber.Ast.Tag).toHaveBeenCalledWith(name, line);
+ expect(Cucumber.Ast.Tag).toHaveBeenCalledWith(name, uri, line);
});
- it("tells the AST assembler to insert the tag into the tree", function() {
+ it("tells the AST assembler to insert the tag into the tree", function () {
parser.handleTag(name, line);
expect(astAssembler.insertTag).toHaveBeenCalledWith(tag);
});
Please sign in to comment.
Something went wrong with that request. Please try again.