Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding 'Background' Support

  • Loading branch information...
commit 00650eb296014ef8a768e3ffb76627a2c314f3a1 1 parent 16c293e
@eugeneware eugeneware authored pacovell committed
Showing with 37 additions and 3 deletions.
  1. +37 −3 lib/kyuri/parser.js
View
40 lib/kyuri/parser.js
@@ -24,7 +24,11 @@ var getLastFeature = function (ast) {
//
var getLastScenario = function (ast) {
var feature = getLastFeature(ast);
- return feature.scenarios[feature.scenarios.length - 1];
+ if (feature.background && feature.background.background) {
+ return feature.background;
+ } else {
+ return feature.scenarios[feature.scenarios.length - 1];
+ }
};
//
@@ -98,7 +102,8 @@ var _states = {
ast[id.toString()] = {
name: token[1],
description: '',
- scenarios: []
+ scenarios: [],
+ background: null
};
return ast[id.toString()];
}
@@ -138,12 +143,36 @@ var _states = {
return feature;
}
},
+ 'BACKGROUND': {
+ value: 'BACKGROUND',
+ next: 'scenario',
+ last: ['TERMINATOR', 'OUTDENT'],
+ build: function (ast, token) {
+ var feature = getLastFeature(ast);
+
+ if (feature.background) {
+ throw new Error('Only one Background per feature is allowed');
+ }
+
+ feature.background = {
+ background: true,
+ outline: false,
+ breakdown: [],
+ };
+ return feature;
+ }
+ },
'SCENARIO': {
value: 'SCENARIO',
next: 'scenario',
last: ['TERMINATOR', 'OUTDENT'],
build: function (ast, token) {
var feature = getLastFeature(ast);
+
+ if (feature.background && feature.background.background) {
+ delete feature.background.background;
+ }
+
feature.scenarios.push({
outline: false,
breakdown: [],
@@ -180,7 +209,12 @@ var _states = {
scenario.name = token[1];
return scenario;
}
- }
+ },
+ 'TERMINATOR': {
+ value: '*',
+ next: 'scenarioHeader',
+ last: ['BACKGROUND', 'SCENARIO', 'SCENARIO_OUTLINE'],
+ },
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.