Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 7 commits
  • 39 files changed
  • 0 commit comments
  • 2 contributors
Commits on Jun 11, 2012
@aslakhellesoy aslakhellesoy Ran a gem update 1f3053d
@aslakhellesoy aslakhellesoy Update NPM dependencies (close #69)
All NPM dependencies were updated to latest except browserify, which caused exceptions. Jasmine and example/server.js still working.
264d097
Commits on Jun 17, 2012
@jbpros jbpros Refactor listener infrastructure (#35, #59, #63)
* Extract common listener behaviour from progress formatter
* Extract stats journal from progress formatter

Theses changes will ease the implementation of new listeners (e.g. the pretty, JSON and jUnit formatters).
837c021
Commits on Jun 19, 2012
@jbpros jbpros Extract summary logger from progress formatter (#59, #63)
Feature run summaries can now be reused among formatters.
3057098
@jbpros jbpros Store URI on AST elements 35c4d25
@jbpros jbpros Display failing scenario URIs in summary bb046a5
@jbpros jbpros Release 0.2.16 d9a889a
Showing with 3,064 additions and 2,214 deletions.
  1. +27 −19 Gemfile.lock
  2. +17 −1 History.md
  3. +1 −1 lib/cucumber.js
  4. +5 −1 lib/cucumber/ast/background.js
  5. +1 −1 lib/cucumber/ast/data_table/row.js
  6. +5 −1 lib/cucumber/ast/doc_string.js
  7. +5 −1 lib/cucumber/ast/feature.js
  8. +5 −1 lib/cucumber/ast/scenario.js
  9. +5 −1 lib/cucumber/ast/step.js
  10. +10 −2 lib/cucumber/ast/tag.js
  11. +37 −1 lib/cucumber/listener.js
  12. +59 −367 lib/cucumber/listener/progress_formatter.js
  13. +213 −0 lib/cucumber/listener/stats_journal.js
  14. +177 −0 lib/cucumber/listener/summary_logger.js
  15. +31 −12 lib/cucumber/parser.js
  16. +9 −9 package.json
  17. +9 −2 spec/cucumber/ast/background_spec.js
  18. +3 −2 spec/cucumber/ast/data_table/row_spec.js
  19. +11 −4 spec/cucumber/ast/doc_string_spec.js
  20. +14 −7 spec/cucumber/ast/feature_spec.js
  21. +4 −4 spec/cucumber/ast/filter/any_of_tags_rule_spec.js
  22. +7 −7 spec/cucumber/ast/filter/element_matching_tag_spec_spec.js
  23. +6 −6 spec/cucumber/ast/filter_spec.js
  24. +9 −2 spec/cucumber/ast/scenario_spec.js
  25. +30 −23 spec/cucumber/ast/step_spec.js
  26. +18 −5 spec/cucumber/ast/tag_spec.js
  27. +1 −1 spec/cucumber/cli/argument_parser/path_expander_spec.js
  28. +2 −2 spec/cucumber/cli/configuration_spec.js
  29. +2 −2 spec/cucumber/cli/support_code_loader_spec.js
  30. +2 −2 spec/cucumber/cli_spec.js
  31. +195 −1,642 spec/cucumber/listener/progress_formatter_spec.js
  32. +787 −0 spec/cucumber/listener/stats_journal_spec.js
  33. +1,055 −0 spec/cucumber/listener/summary_logger_spec.js
  34. +148 −0 spec/cucumber/listener_spec.js
  35. +141 −72 spec/cucumber/parser_spec.js
  36. +6 −6 spec/cucumber/runtime/ast_tree_walker_spec.js
  37. +2 −2 spec/cucumber/support_code/hook_spec.js
  38. +4 −4 spec/cucumber/support_code/step_definition_snippet_builder_spec.js
  39. +1 −1 spec/cucumber/support_code/step_definition_spec.js
View
46 Gemfile.lock
@@ -7,33 +7,41 @@ GEM
ffi (= 1.0.9)
rspec (>= 2.7.0)
builder (3.0.0)
- childprocess (0.2.3)
+ childprocess (0.3.2)
ffi (~> 1.0.6)
- cucumber (1.1.3)
+ cucumber (1.2.1)
builder (>= 2.1.2)
- diff-lcs (>= 1.1.2)
- gherkin (~> 2.6.7)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.11.0)
json (>= 1.4.6)
- term-ansicolor (>= 1.0.6)
diff-lcs (1.1.3)
ffi (1.0.9)
- gherkin (2.6.8)
+ gherkin (2.11.0)
json (>= 1.4.6)
- guard (0.8.2)
- thor (~> 0.14.6)
+ guard (1.1.1)
+ listen (>= 0.4.2)
+ thor (>= 0.14.6)
guard-jasmine-node (0.0.5)
guard (>= 0.4)
- json (1.6.3)
- rspec (2.7.0)
- rspec-core (~> 2.7.0)
- rspec-expectations (~> 2.7.0)
- rspec-mocks (~> 2.7.0)
- rspec-core (2.7.1)
- rspec-expectations (2.7.0)
- diff-lcs (~> 1.1.2)
- rspec-mocks (2.7.0)
- term-ansicolor (1.0.7)
- thor (0.14.6)
+ json (1.7.3)
+ listen (0.4.4)
+ rb-fchange (~> 0.0.5)
+ rb-fsevent (~> 0.9.1)
+ rb-inotify (~> 0.8.8)
+ rb-fchange (0.0.5)
+ ffi
+ rb-fsevent (0.9.1)
+ rb-inotify (0.8.8)
+ ffi (>= 0.5.0)
+ rspec (2.10.0)
+ rspec-core (~> 2.10.0)
+ rspec-expectations (~> 2.10.0)
+ rspec-mocks (~> 2.10.0)
+ rspec-core (2.10.1)
+ rspec-expectations (2.10.0)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.10.1)
+ thor (0.15.2)
PLATFORMS
ruby
View
18 History.md
@@ -2,10 +2,26 @@
## [v0.2](https://github.com/cucumber/cucumber-js/compare/v0.1.5...master)
-### [master (unreleased)](https://github.com/cucumber/cucumber-js/compare/v0.2.15...master)
+### [master (unreleased)](https://github.com/cucumber/cucumber-js/compare/v0.2.16...master)
**TBD**
+### [v0.2.16](https://github.com/cucumber/cucumber-js/compare/v0.2.15...v0.2.16)
+
+
+#### New features
+
+* Display failing scenario URIs in summary (Julien Biezemans)
+
+#### Documentation, internals and tests
+
+* Ran a gem update (Aslak Hellesøy)
+* Update NPM dependencies (#69) (Aslak Hellesøy)
+* Refactor listener infrastructure (#35, #59, #63) (Julien Biezemans)
+* Extract summary logger from progress formatter (#59, #63) (Julien Biezemans)
+* Store URI on AST elements (Julien Biezemans)
+
+
### [v0.2.15](https://github.com/cucumber/cucumber-js/compare/v0.2.14...v0.2.15)
View
2 lib/cucumber.js
@@ -16,6 +16,6 @@ Cucumber.Type = require('./cucumber/type');
Cucumber.Util = require('./cucumber/util');
Cucumber.VolatileConfiguration = require('./cucumber/volatile_configuration');
-Cucumber.VERSION = "0.2.15";
+Cucumber.VERSION = "0.2.16";
module.exports = Cucumber;
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
38 lib/cucumber/listener.js
@@ -1,3 +1,39 @@
-var Listener = {};
+var Listener = function () {
+ var self = {
+ hear: function hear(event, callback) {
+ if (self.hasHandlerForEvent(event)) {
+ var handler = self.getHandlerForEvent(event);
+ handler(event, callback);
+ } else {
+ callback();
+ }
+ },
+
+ hasHandlerForEvent: function hasHandlerForEvent(event) {
+ var handlerName = self.buildHandlerNameForEvent(event);
+ return self[handlerName] != undefined;
+ },
+
+ buildHandlerNameForEvent: function buildHandlerNameForEvent(event) {
+ var handlerName =
+ Listener.EVENT_HANDLER_NAME_PREFIX +
+ event.getName() +
+ Listener.EVENT_HANDLER_NAME_SUFFIX;
+ return handlerName;
+ },
+
+ getHandlerForEvent: function getHandlerForEvent(event) {
+ var eventHandlerName = self.buildHandlerNameForEvent(event);
+ return self[eventHandlerName];
+ }
+ };
+ return self;
+};
+
+Listener.EVENT_HANDLER_NAME_PREFIX = 'handle';
+Listener.EVENT_HANDLER_NAME_SUFFIX = 'Event';
+
Listener.ProgressFormatter = require('./listener/progress_formatter');
+Listener.StatsJournal = require('./listener/stats_journal');
+Listener.SummaryLogger = require('./listener/summary_logger');
module.exports = Listener;
View
426 lib/cucumber/listener/progress_formatter.js
@@ -1,389 +1,81 @@
var ProgressFormatter = function(options) {
var Cucumber = require('../../cucumber');
- var logs = "";
- var failedScenarioLogBuffer = "";
- var undefinedStepLogBuffer = "";
- var passedScenarioCount = 0;
- var undefinedScenarioCount = 0;
- var pendingScenarioCount = 0;
- var failedScenarioCount = 0;
- var passedStepCount = 0;
- var failedStepCount = 0;
- var skippedStepCount = 0;
- var undefinedStepCount = 0;
- var pendingStepCount = 0;
- var currentScenarioFailing = false;
- var currentScenarioUndefined = false;
- var currentScenarioPending = false;
- var failedStepResults = Cucumber.Type.Collection();
+ var logs = "";
if (!options)
options = {};
if (options['logToConsole'] == undefined)
options['logToConsole'] = true;
- var self = {
- log: function log(string) {
- logs += string;
- if (options['logToConsole'])
- process.stdout.write(string);
- if (typeof(options['logToFunction']) == 'function')
- options['logToFunction'](string);
- },
- getLogs: function getLogs() {
- return logs;
- },
+ var self = Cucumber.Listener();
+ var summaryLogger = Cucumber.Listener.SummaryLogger();
- hear: function hear(event, callback) {
- if (self.hasHandlerForEvent(event)) {
- var handler = self.getHandlerForEvent(event);
- handler(event, callback);
- } else {
- callback();
- }
- },
-
- hasHandlerForEvent: function hasHandlerForEvent(event) {
- var handlerName = self.buildHandlerNameForEvent(event);
- return self[handlerName] != undefined;
- },
-
- buildHandlerNameForEvent: function buildHandlerNameForEvent(event) {
- var handlerName =
- ProgressFormatter.EVENT_HANDLER_NAME_PREFIX +
- event.getName() +
- ProgressFormatter.EVENT_HANDLER_NAME_SUFFIX;
- return handlerName;
- },
-
- getHandlerForEvent: function getHandlerForEvent(event) {
- var eventHandlerName = self.buildHandlerNameForEvent(event);
- return self[eventHandlerName];
- },
-
- handleBeforeScenarioEvent: function handleBeforeScenarioEvent(event, callback) {
- self.prepareBeforeScenario();
- callback();
- },
-
- handleStepResultEvent: function handleStepResult(event, callback) {
- var stepResult = event.getPayloadItem('stepResult');
- if (stepResult.isSuccessful())
- self.handleSuccessfulStepResult();
- else if (stepResult.isPending())
- self.handlePendingStepResult();
- else if (stepResult.isSkipped())
- self.handleSkippedStepResult();
- else if (stepResult.isUndefined())
- self.handleUndefinedStepResult(stepResult);
- else
- self.handleFailedStepResult(stepResult);
- callback();
- },
-
- handleSuccessfulStepResult: function handleSuccessfulStepResult() {
- self.witnessPassedStep();
- self.log(ProgressFormatter.PASSED_STEP_CHARACTER);
- },
-
- handlePendingStepResult: function handlePendingStepResult() {
- self.witnessPendingStep();
- self.markCurrentScenarioAsPending();
- self.log(ProgressFormatter.PENDING_STEP_CHARACTER);
- },
-
- handleSkippedStepResult: function handleSkippedStepResult() {
- self.witnessSkippedStep();
- self.log(ProgressFormatter.SKIPPED_STEP_CHARACTER);
- },
-
- handleUndefinedStepResult: function handleUndefinedStepResult(stepResult) {
- var step = stepResult.getStep();
- self.storeUndefinedStep(step);
- self.witnessUndefinedStep();
- self.markCurrentScenarioAsUndefined();
- self.log(ProgressFormatter.UNDEFINED_STEP_CHARACTER);
- },
-
- handleFailedStepResult: function handleFailedStepResult(stepResult) {
- self.storeFailedStepResult(stepResult);
- self.witnessFailedStep();
- self.markCurrentScenarioAsFailing();
- self.log(ProgressFormatter.FAILED_STEP_CHARACTER);
- },
-
- handleAfterFeaturesEvent: function handleAfterFeaturesEvent(event, callback) {
- self.logSummary();
- callback();
- },
-
- handleAfterScenarioEvent: function handleAfterScenarioEvent(event, callback) {
- if (self.isCurrentScenarioFailing()) {
- var scenario = event.getPayloadItem('scenario');
- self.storeFailedScenario(scenario);
- self.witnessFailedScenario();
- } else if (self.isCurrentScenarioUndefined()) {
- self.witnessUndefinedScenario();
- } else if (self.isCurrentScenarioPending()) {
- self.witnessPendingScenario();
- } else {
- self.witnessPassedScenario();
- }
- callback();
- },
-
- prepareBeforeScenario: function prepareBeforeScenario() {
- currentScenarioFailing = false;
- currentScenarioPending = false;
- currentScenarioUndefined = false;
- },
-
- markCurrentScenarioAsFailing: function markCurrentScenarioAsFailing() {
- currentScenarioFailing = true;
- },
-
- markCurrentScenarioAsUndefined: function markCurrentScenarioAsUndefined() {
- currentScenarioUndefined = true;
- },
-
- markCurrentScenarioAsPending: function markCurrentScenarioAsPending() {
- currentScenarioPending = true;
- },
-
- isCurrentScenarioFailing: function isCurrentScenarioFailing() {
- return currentScenarioFailing;
- },
-
- isCurrentScenarioUndefined: function isCurrentScenarioUndefined() {
- return currentScenarioUndefined;
- },
-
- isCurrentScenarioPending: function isCurrentScenarioPending() {
- return currentScenarioPending;
- },
-
- storeFailedStepResult: function storeFailedStepResult(failedStepResult) {
- failedStepResults.add(failedStepResult);
- },
-
- storeFailedScenario: function storeFailedScenario(failedScenario) {
- var name = failedScenario.getName();
- var line = failedScenario.getLine();
- self.appendStringToFailedScenarioLogBuffer(":" + line + " # Scenario: " + name);
- },
-
- storeUndefinedStep: function storeUndefinedStep(step) {
- var snippetBuilder = Cucumber.SupportCode.StepDefinitionSnippetBuilder(step);
- var snippet = snippetBuilder.buildSnippet();
- self.appendStringToUndefinedStepLogBuffer(snippet);
- },
-
- appendStringToFailedScenarioLogBuffer: function appendStringToFailedScenarioLogBuffer(string) {
- failedScenarioLogBuffer += string + "\n";
- },
-
- appendStringToUndefinedStepLogBuffer: function appendStringToUndefinedStepLogBuffer(string) {
- if (undefinedStepLogBuffer.indexOf(string) == -1)
- undefinedStepLogBuffer += string + "\n";
- },
-
- getFailedScenarioLogBuffer: function getFailedScenarioLogBuffer() {
- return failedScenarioLogBuffer;
- },
-
- getUndefinedStepLogBuffer: function getUndefinedStepLogBuffer() {
- return undefinedStepLogBuffer;
- },
-
- logSummary: function logSummary() {
- self.log("\n\n");
- if (self.witnessedAnyFailedStep())
- self.logFailedStepResults();
- self.logScenariosSummary();
- self.logStepsSummary();
- if (self.witnessedAnyUndefinedStep())
- self.logUndefinedStepSnippets();
- },
-
- logFailedStepResults: function logFailedStepResults() {
- self.log("(::) failed steps (::)\n\n");
- failedStepResults.syncForEach(function(stepResult) {
- self.logFailedStepResult(stepResult);
- });
- self.log("Failing scenarios:\n");
- var failedScenarios = self.getFailedScenarioLogBuffer();
- self.log(failedScenarios);
- self.log("\n");
- },
-
- logFailedStepResult: function logFailedStepResult(stepResult) {
- var failureMessage = stepResult.getFailureException();
- self.log(failureMessage.stack || failureMessage);
- self.log("\n\n");
- },
-
- logScenariosSummary: function logScenariosSummary() {
- var scenarioCount = self.getScenarioCount();
- var passedScenarioCount = self.getPassedScenarioCount();
- var undefinedScenarioCount = self.getUndefinedScenarioCount();
- var pendingScenarioCount = self.getPendingScenarioCount();
- var failedScenarioCount = self.getFailedScenarioCount();
- var details = [];
-
- self.log(scenarioCount + " scenario" + (scenarioCount != 1 ? "s" : ""));
- if (scenarioCount > 0 ) {
- if (failedScenarioCount > 0)
- details.push(failedScenarioCount + " failed");
- if (undefinedScenarioCount > 0)
- details.push(undefinedScenarioCount + " undefined");
- if (pendingScenarioCount > 0)
- details.push(pendingScenarioCount + " pending");
- if (passedScenarioCount > 0)
- details.push(passedScenarioCount + " passed");
- self.log(" (" + details.join(', ') + ")");
- }
- self.log("\n");
- },
-
- logStepsSummary: function logStepsSummary() {
- var stepCount = self.getStepCount();
- var passedStepCount = self.getPassedStepCount();
- var undefinedStepCount = self.getUndefinedStepCount();
- var skippedStepCount = self.getSkippedStepCount();
- var pendingStepCount = self.getPendingStepCount();
- var failedStepCount = self.getFailedStepCount();
- var details = [];
-
- self.log(stepCount + " step" + (stepCount != 1 ? "s" : ""));
- if (stepCount > 0) {
- if (failedStepCount > 0)
- details.push(failedStepCount + " failed");
- if (undefinedStepCount > 0)
- details.push(undefinedStepCount + " undefined");
- if (pendingStepCount > 0)
- details.push(pendingStepCount + " pending");
- if (skippedStepCount > 0)
- details.push(skippedStepCount + " skipped");
- if (passedStepCount > 0)
- details.push(passedStepCount + " passed");
- self.log(" (" + details.join(', ') + ")");
- }
- self.log("\n");
- },
-
- logUndefinedStepSnippets: function logUndefinedStepSnippets() {
- var undefinedStepLogBuffer = self.getUndefinedStepLogBuffer();
- self.log("\nYou can implement step definitions for undefined steps with these snippets:\n\n");
- self.log(undefinedStepLogBuffer);
- },
-
- witnessPassedScenario: function witnessPassedScenario() {
- passedScenarioCount++;
- },
-
- witnessUndefinedScenario: function witnessUndefinedScenario() {
- undefinedScenarioCount++;
- },
-
- witnessPendingScenario: function witnessPendingScenario() {
- pendingScenarioCount++;
- },
-
- witnessFailedScenario: function witnessFailedScenario() {
- failedScenarioCount++;
- },
-
- witnessPassedStep: function witnessPassedStep() {
- passedStepCount++;
- },
-
- witnessUndefinedStep: function witnessUndefinedStep() {
- undefinedStepCount++;
- },
-
- witnessPendingStep: function witnessPendingStep() {
- pendingStepCount++;
- },
-
- witnessFailedStep: function witnessFailedStep() {
- failedStepCount++;
- },
-
- witnessSkippedStep: function witnessSkippedStep() {
- skippedStepCount++;
- },
-
- getScenarioCount: function getScenarioCount() {
- var scenarioCount =
- self.getPassedScenarioCount() +
- self.getUndefinedScenarioCount() +
- self.getPendingScenarioCount() +
- self.getFailedScenarioCount();
- return scenarioCount;
- },
-
- getPassedScenarioCount: function getPassedScenarioCount() {
- return passedScenarioCount;
- },
-
- getUndefinedScenarioCount: function getUndefinedScenarioCount() {
- return undefinedScenarioCount;
- },
-
- getPendingScenarioCount: function getPendingScenarioCount() {
- return pendingScenarioCount;
- },
+ var parentHear = self.hear;
+ self.hear = function hear(event, callback) {
+ summaryLogger.hear(event, function () {
+ parentHear(event, callback);
+ });
+ };
- getFailedScenarioCount: function getFailedScenarioCount() {
- return failedScenarioCount;
- },
+ self.log = function log(string) {
+ logs += string;
+ if (options['logToConsole'])
+ process.stdout.write(string);
+ if (typeof(options['logToFunction']) == 'function')
+ options['logToFunction'](string);
+ };
- getStepCount: function getStepCount() {
- var stepCount =
- self.getPassedStepCount() +
- self.getUndefinedStepCount() +
- self.getSkippedStepCount() +
- self.getPendingStepCount() +
- self.getFailedStepCount();
- return stepCount;
- },
+ self.getLogs = function getLogs() {
+ return logs;
+ };
- getPassedStepCount: function getPassedStepCount() {
- return passedStepCount;
- },
+ self.handleStepResultEvent = function handleStepResult(event, callback) {
+ var stepResult = event.getPayloadItem('stepResult');
+ if (stepResult.isSuccessful())
+ self.handleSuccessfulStepResult();
+ else if (stepResult.isPending())
+ self.handlePendingStepResult();
+ else if (stepResult.isSkipped())
+ self.handleSkippedStepResult();
+ else if (stepResult.isUndefined())
+ self.handleUndefinedStepResult();
+ else
+ self.handleFailedStepResult();
+ callback();
+ };
- getPendingStepCount: function getPendingStepCount() {
- return pendingStepCount;
- },
+ self.handleSuccessfulStepResult = function handleSuccessfulStepResult() {
+ self.log(ProgressFormatter.PASSED_STEP_CHARACTER);
+ };
- getFailedStepCount: function getFailedStepCount() {
- return failedStepCount;
- },
+ self.handlePendingStepResult = function handlePendingStepResult() {
+ self.log(ProgressFormatter.PENDING_STEP_CHARACTER);
+ };
- getSkippedStepCount: function getSkippedStepCount() {
- return skippedStepCount;
- },
+ self.handleSkippedStepResult = function handleSkippedStepResult() {
+ self.log(ProgressFormatter.SKIPPED_STEP_CHARACTER);
+ };
- getUndefinedStepCount: function getUndefinedStepCount() {
- return undefinedStepCount;
- },
+ self.handleUndefinedStepResult = function handleUndefinedStepResult() {
+ self.log(ProgressFormatter.UNDEFINED_STEP_CHARACTER);
+ };
- witnessedAnyFailedStep: function witnessedAnyFailedStep() {
- return failedStepCount > 0;
- },
+ self.handleFailedStepResult = function handleFailedStepResult() {
+ self.log(ProgressFormatter.FAILED_STEP_CHARACTER);
+ };
- witnessedAnyUndefinedStep: function witnessedAnyUndefinedStep() {
- return undefinedStepCount > 0;
- }
+ self.handleAfterFeaturesEvent = function handleAfterFeaturesEvent(event, callback) {
+ var summaryLogs = summaryLogger.getLogs();
+ self.log(summaryLogs);
+ callback();
};
+
return self;
};
-ProgressFormatter.PASSED_STEP_CHARACTER = '.';
-ProgressFormatter.SKIPPED_STEP_CHARACTER = '-';
-ProgressFormatter.UNDEFINED_STEP_CHARACTER = 'U';
-ProgressFormatter.PENDING_STEP_CHARACTER = 'P';
-ProgressFormatter.FAILED_STEP_CHARACTER = 'F';
-ProgressFormatter.EVENT_HANDLER_NAME_PREFIX = 'handle';
-ProgressFormatter.EVENT_HANDLER_NAME_SUFFIX = 'Event';
-module.exports = ProgressFormatter;
+ProgressFormatter.PASSED_STEP_CHARACTER = '.';
+ProgressFormatter.SKIPPED_STEP_CHARACTER = '-';
+ProgressFormatter.UNDEFINED_STEP_CHARACTER = 'U';
+ProgressFormatter.PENDING_STEP_CHARACTER = 'P';
+ProgressFormatter.FAILED_STEP_CHARACTER = 'F';
+module.exports = ProgressFormatter;
View
213 lib/cucumber/listener/stats_journal.js
@@ -0,0 +1,213 @@
+var StatsJournal = function(options) {
+ var Cucumber = require('../../cucumber');
+
+ var passedScenarioCount = 0;
+ var undefinedScenarioCount = 0;
+ var pendingScenarioCount = 0;
+ var failedScenarioCount = 0;
+ var passedStepCount = 0;
+ var failedStepCount = 0;
+ var skippedStepCount = 0;
+ var undefinedStepCount = 0;
+ var pendingStepCount = 0;
+ var currentScenarioFailing = false;
+ var currentScenarioUndefined = false;
+ var currentScenarioPending = false;
+
+ if (!options)
+ options = {};
+
+ var self = Cucumber.Listener();
+
+ self.handleBeforeScenarioEvent = function handleBeforeScenarioEvent(event, callback) {
+ self.prepareBeforeScenario();
+ callback();
+ };
+
+ self.handleStepResultEvent = function handleStepResult(event, callback) {
+ var stepResult = event.getPayloadItem('stepResult');
+ if (stepResult.isSuccessful())
+ self.handleSuccessfulStepResult();
+ else if (stepResult.isPending())
+ self.handlePendingStepResult();
+ else if (stepResult.isSkipped())
+ self.handleSkippedStepResult();
+ else if (stepResult.isUndefined())
+ self.handleUndefinedStepResult(stepResult);
+ else
+ self.handleFailedStepResult(stepResult);
+ callback();
+ };
+
+ self.handleSuccessfulStepResult = function handleSuccessfulStepResult() {
+ self.witnessPassedStep();
+ };
+
+ self.handlePendingStepResult = function handlePendingStepResult() {
+ self.witnessPendingStep();
+ self.markCurrentScenarioAsPending();
+ };
+
+ self.handleSkippedStepResult = function handleSkippedStepResult() {
+ self.witnessSkippedStep();
+ };
+
+ self.handleUndefinedStepResult = function handleUndefinedStepResult(stepResult) {
+ var step = stepResult.getStep();
+ self.witnessUndefinedStep();
+ self.markCurrentScenarioAsUndefined();
+ };
+
+ self.handleFailedStepResult = function handleFailedStepResult(stepResult) {
+ self.witnessFailedStep();
+ self.markCurrentScenarioAsFailing();
+ };
+
+ self.handleAfterScenarioEvent = function handleAfterScenarioEvent(event, callback) {
+ if (self.isCurrentScenarioFailing()) {
+ var scenario = event.getPayloadItem('scenario');
+ self.witnessFailedScenario();
+ } else if (self.isCurrentScenarioUndefined()) {
+ self.witnessUndefinedScenario();
+ } else if (self.isCurrentScenarioPending()) {
+ self.witnessPendingScenario();
+ } else {
+ self.witnessPassedScenario();
+ }
+ callback();
+ };
+
+ self.prepareBeforeScenario = function prepareBeforeScenario() {
+ currentScenarioFailing = false;
+ currentScenarioPending = false;
+ currentScenarioUndefined = false;
+ };
+
+ self.markCurrentScenarioAsFailing = function markCurrentScenarioAsFailing() {
+ currentScenarioFailing = true;
+ };
+
+ self.markCurrentScenarioAsUndefined = function markCurrentScenarioAsUndefined() {
+ currentScenarioUndefined = true;
+ };
+
+ self.markCurrentScenarioAsPending = function markCurrentScenarioAsPending() {
+ currentScenarioPending = true;
+ };
+
+ self.isCurrentScenarioFailing = function isCurrentScenarioFailing() {
+ return currentScenarioFailing;
+ };
+
+ self.isCurrentScenarioUndefined = function isCurrentScenarioUndefined() {
+ return currentScenarioUndefined;
+ };
+
+ self.isCurrentScenarioPending = function isCurrentScenarioPending() {
+ return currentScenarioPending;
+ };
+
+ self.witnessPassedScenario = function witnessPassedScenario() {
+ passedScenarioCount++;
+ };
+
+ self.witnessUndefinedScenario = function witnessUndefinedScenario() {
+ undefinedScenarioCount++;
+ };
+
+ self.witnessPendingScenario = function witnessPendingScenario() {
+ pendingScenarioCount++;
+ };
+
+ self.witnessFailedScenario = function witnessFailedScenario() {
+ failedScenarioCount++;
+ };
+
+ self.witnessPassedStep = function witnessPassedStep() {
+ passedStepCount++;
+ };
+
+ self.witnessUndefinedStep = function witnessUndefinedStep() {
+ undefinedStepCount++;
+ };
+
+ self.witnessPendingStep = function witnessPendingStep() {
+ pendingStepCount++;
+ };
+
+ self.witnessFailedStep = function witnessFailedStep() {
+ failedStepCount++;
+ };
+
+ self.witnessSkippedStep = function witnessSkippedStep() {
+ skippedStepCount++;
+ };
+
+ self.getScenarioCount = function getScenarioCount() {
+ var scenarioCount =
+ self.getPassedScenarioCount() +
+ self.getUndefinedScenarioCount() +
+ self.getPendingScenarioCount() +
+ self.getFailedScenarioCount();
+ return scenarioCount;
+ };
+
+ self.getPassedScenarioCount = function getPassedScenarioCount() {
+ return passedScenarioCount;
+ };
+
+ self.getUndefinedScenarioCount = function getUndefinedScenarioCount() {
+ return undefinedScenarioCount;
+ };
+
+ self.getPendingScenarioCount = function getPendingScenarioCount() {
+ return pendingScenarioCount;
+ };
+
+ self.getFailedScenarioCount = function getFailedScenarioCount() {
+ return failedScenarioCount;
+ };
+
+ self.getStepCount = function getStepCount() {
+ var stepCount =
+ self.getPassedStepCount() +
+ self.getUndefinedStepCount() +
+ self.getSkippedStepCount() +
+ self.getPendingStepCount() +
+ self.getFailedStepCount();
+ return stepCount;
+ };
+
+ self.getPassedStepCount = function getPassedStepCount() {
+ return passedStepCount;
+ };
+
+ self.getPendingStepCount = function getPendingStepCount() {
+ return pendingStepCount;
+ };
+
+ self.getFailedStepCount = function getFailedStepCount() {
+ return failedStepCount;
+ };
+
+ self.getSkippedStepCount = function getSkippedStepCount() {
+ return skippedStepCount;
+ };
+
+ self.getUndefinedStepCount = function getUndefinedStepCount() {
+ return undefinedStepCount;
+ };
+
+ self.witnessedAnyFailedStep = function witnessedAnyFailedStep() {
+ return failedStepCount > 0;
+ };
+
+ self.witnessedAnyUndefinedStep = function witnessedAnyUndefinedStep() {
+ return undefinedStepCount > 0;
+ };
+
+ return self;
+};
+StatsJournal.EVENT_HANDLER_NAME_PREFIX = 'handle';
+StatsJournal.EVENT_HANDLER_NAME_SUFFIX = 'Event';
+module.exports = StatsJournal;
View
177 lib/cucumber/listener/summary_logger.js
@@ -0,0 +1,177 @@
+var SummaryLogger = function () {
+ var Cucumber = require('../../cucumber');
+
+ var logs = "";
+ var failedScenarioLogBuffer = "";
+ var undefinedStepLogBuffer = "";
+ var failedStepResults = Cucumber.Type.Collection();
+ var statsJournal = Cucumber.Listener.StatsJournal();
+
+ var self = Cucumber.Listener();
+
+ var parentHear = self.hear;
+ self.hear = function hear(event, callback) {
+ statsJournal.hear(event, function () {
+ parentHear(event, callback);
+ });
+ };
+
+ self.log = function log(string) {
+ logs += string;
+ };
+
+ self.getLogs = function getLogs() {
+ return logs;
+ };
+
+ self.handleStepResultEvent = function handleStepResult(event, callback) {
+ var stepResult = event.getPayloadItem('stepResult');
+ if (stepResult.isUndefined()) {
+ self.handleUndefinedStepResult(stepResult);
+ } else if (stepResult.isFailed()) {
+ self.handleFailedStepResult(stepResult);
+ }
+ callback();
+ };
+
+ self.handleUndefinedStepResult = function handleUndefinedStepResult(stepResult) {
+ var step = stepResult.getStep();
+ self.storeUndefinedStep(step);
+ };
+
+ self.handleFailedStepResult = function handleFailedStepResult(stepResult) {
+ self.storeFailedStepResult(stepResult);
+ };
+
+ self.handleAfterScenarioEvent = function handleAfterScenarioEvent(event, callback) {
+ if (statsJournal.isCurrentScenarioFailing()) {
+ var scenario = event.getPayloadItem('scenario');
+ self.storeFailedScenario(scenario);
+ }
+ callback();
+ };
+
+ self.handleAfterFeaturesEvent = function handleAfterFeaturesEvent(event, callback) {
+ self.logSummary();
+ callback();
+ };
+
+ self.storeFailedStepResult = function storeFailedStepResult(failedStepResult) {
+ failedStepResults.add(failedStepResult);
+ };
+
+ self.storeFailedScenario = function storeFailedScenario(failedScenario) {
+ var name = failedScenario.getName();
+ var uri = failedScenario.getUri();
+ var line = failedScenario.getLine();
+ self.appendStringToFailedScenarioLogBuffer(uri + ":" + line + " # Scenario: " + name);
+ };
+
+ self.storeUndefinedStep = function storeUndefinedStep(step) {
+ var snippetBuilder = Cucumber.SupportCode.StepDefinitionSnippetBuilder(step);
+ var snippet = snippetBuilder.buildSnippet();
+ self.appendStringToUndefinedStepLogBuffer(snippet);
+ };
+
+ self.appendStringToFailedScenarioLogBuffer = function appendStringToFailedScenarioLogBuffer(string) {
+ failedScenarioLogBuffer += string + "\n";
+ };
+
+ self.appendStringToUndefinedStepLogBuffer = function appendStringToUndefinedStepLogBuffer(string) {
+ if (undefinedStepLogBuffer.indexOf(string) == -1)
+ undefinedStepLogBuffer += string + "\n";
+ };
+
+ self.getFailedScenarioLogBuffer = function getFailedScenarioLogBuffer() {
+ return failedScenarioLogBuffer;
+ };
+
+ self.getUndefinedStepLogBuffer = function getUndefinedStepLogBuffer() {
+ return undefinedStepLogBuffer;
+ };
+
+ self.logSummary = function logSummary() {
+ self.log("\n\n");
+ if (statsJournal.witnessedAnyFailedStep())
+ self.logFailedStepResults();
+ self.logScenariosSummary();
+ self.logStepsSummary();
+ if (statsJournal.witnessedAnyUndefinedStep())
+ self.logUndefinedStepSnippets();
+ };
+
+ self.logFailedStepResults = function logFailedStepResults() {
+ self.log("(::) failed steps (::)\n\n");
+ failedStepResults.syncForEach(function(stepResult) {
+ self.logFailedStepResult(stepResult);
+ });
+ self.log("Failing scenarios:\n");
+ var failedScenarios = self.getFailedScenarioLogBuffer();
+ self.log(failedScenarios);
+ self.log("\n");
+ };
+
+ self.logFailedStepResult = function logFailedStepResult(stepResult) {
+ var failureMessage = stepResult.getFailureException();
+ self.log(failureMessage.stack || failureMessage);
+ self.log("\n\n");
+ };
+
+ self.logScenariosSummary = function logScenariosSummary() {
+ var scenarioCount = statsJournal.getScenarioCount();
+ var passedScenarioCount = statsJournal.getPassedScenarioCount();
+ var undefinedScenarioCount = statsJournal.getUndefinedScenarioCount();
+ var pendingScenarioCount = statsJournal.getPendingScenarioCount();
+ var failedScenarioCount = statsJournal.getFailedScenarioCount();
+ var details = [];
+
+ self.log(scenarioCount + " scenario" + (scenarioCount != 1 ? "s" : ""));
+ if (scenarioCount > 0 ) {
+ if (failedScenarioCount > 0)
+ details.push(failedScenarioCount + " failed");
+ if (undefinedScenarioCount > 0)
+ details.push(undefinedScenarioCount + " undefined");
+ if (pendingScenarioCount > 0)
+ details.push(pendingScenarioCount + " pending");
+ if (passedScenarioCount > 0)
+ details.push(passedScenarioCount + " passed");
+ self.log(" (" + details.join(', ') + ")");
+ }
+ self.log("\n");
+ };
+
+ self.logStepsSummary = function logStepsSummary() {
+ var stepCount = statsJournal.getStepCount();
+ var passedStepCount = statsJournal.getPassedStepCount();
+ var undefinedStepCount = statsJournal.getUndefinedStepCount();
+ var skippedStepCount = statsJournal.getSkippedStepCount();
+ var pendingStepCount = statsJournal.getPendingStepCount();
+ var failedStepCount = statsJournal.getFailedStepCount();
+ var details = [];
+
+ self.log(stepCount + " step" + (stepCount != 1 ? "s" : ""));
+ if (stepCount > 0) {
+ if (failedStepCount > 0)
+ details.push(failedStepCount + " failed");
+ if (undefinedStepCount > 0)
+ details.push(undefinedStepCount + " undefined");
+ if (pendingStepCount > 0)
+ details.push(pendingStepCount + " pending");
+ if (skippedStepCount > 0)
+ details.push(skippedStepCount + " skipped");
+ if (passedStepCount > 0)
+ details.push(passedStepCount + " passed");
+ self.log(" (" + details.join(', ') + ")");
+ }
+ self.log("\n");
+ };
+
+ self.logUndefinedStepSnippets = function logUndefinedStepSnippets() {
+ var undefinedStepLogBuffer = self.getUndefinedStepLogBuffer();
+ self.log("\nYou can implement step definitions for undefined steps with these snippets:\n\n");
+ self.log(undefinedStepLogBuffer);
+ };
+
+ return self;
+};
+module.exports = SummaryLogger;
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
18 package.json
@@ -1,7 +1,7 @@
{ "name" : "cucumber"
, "description" : "The official JavaScript implementation of Cucumber."
, "keywords" : [ "testing", "bdd", "cucumber", "gherkin", "tests" ]
-, "version" : "0.2.15"
+, "version" : "0.2.16"
, "homepage" : "http://github.com/cucumber/cucumber-js"
, "author" : "Julien Biezemans <jb@jbpros.com> (http://jbpros.net)"
, "contributors" : [
@@ -25,17 +25,17 @@
, "main" : "./lib/cucumber"
, "engines" : { "node" : "0.4 || 0.5 || 0.6" }
, "dependencies" :
- { "gherkin" : "2.6.8"
- , "jasmine-node" : "1.0.13"
- , "connect" : "1.8.1"
+ { "gherkin" : "2.11.0"
+ , "jasmine-node" : "1.0.26"
+ , "connect" : "2.3.2"
, "browserify" : "1.8.1"
, "nopt" : "1.0.10"
- , "underscore" : "1.2.2"
- , "rimraf" : "1.0.8"
- , "mkdirp" : "0.2.1"
+ , "underscore" : "1.3.3"
+ , "rimraf" : "2.0.2"
+ , "mkdirp" : "0.3.3"
, "cucumber-html": "0.2.0"
- , "findit": "0.1.1"
- , "coffee-script": "1.1.2"
+ , "findit": "0.1.2"
+ , "coffee-script": "1.3.3"
}
, "scripts" :
{ "test" : "./bin/cucumber.js && jasmine-node spec" }
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
21 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);
@@ -173,7 +180,7 @@ describe("Cucumber.Ast.Feature", function() {
spyOn(feature, 'hasBackground');
});
- it("checks wether the feature has a background", function() {
+ it("checks whether the feature has a background", function() {
feature.instructVisitorToVisitBackground(visitor, callback);
expect(feature.hasBackground).toHaveBeenCalled();
});
View
8 spec/cucumber/ast/filter/any_of_tags_rule_spec.js
@@ -17,7 +17,7 @@ describe("Cucumber.Ast.Filter.AnyOfTagsRule", function() {
beforeEach(function() {
element = createSpy("element");
- satisfyingElement = createSpy("wether the element is satisfying");
+ satisfyingElement = createSpy("whether the element is satisfying");
spyOn(_, 'any').andReturn(satisfyingElement);
});
@@ -32,7 +32,7 @@ describe("Cucumber.Ast.Filter.AnyOfTagsRule", function() {
var spec, everyTagConditionFunc, tag, matchingSpec;
beforeEach(function() {
- matchingSpec = createSpy("wether the spec is satisfied or not");
+ matchingSpec = createSpy("whether the spec is satisfied or not");
tag = createSpy("tag");
spec = createSpyWithStubs("element matching tag spec", {isMatching: matchingSpec});
rule.isSatisfiedByElement(element);
@@ -45,7 +45,7 @@ describe("Cucumber.Ast.Filter.AnyOfTagsRule", function() {
expect(Cucumber.Ast.Filter.ElementMatchingTagSpec).toHaveBeenCalledWith(tag);
});
- it("checks wether the element is matching the spec", function() {
+ it("checks whether the element is matching the spec", function() {
everyTagConditionFunc(tag);
expect(spec.isMatching).toHaveBeenCalledWith(element);
});
@@ -55,7 +55,7 @@ describe("Cucumber.Ast.Filter.AnyOfTagsRule", function() {
});
});
- it("returns wether it found a matching tag or not", function() {
+ it("returns whether it found a matching tag or not", function() {
expect(rule.isSatisfiedByElement(element)).toBe(satisfyingElement);
});
});
View
14 spec/cucumber/ast/filter/element_matching_tag_spec_spec.js
@@ -18,7 +18,7 @@ describe("Cucumber.Ast.Filter.ElementMatchingTagSpec", function() {
beforeEach(function() {
elementTags = createSpy("element tags");
element = createSpyWithStubs("element", {getTags: elementTags});
- matchingElement = createSpy("wether the element is matching or not");
+ matchingElement = createSpy("whether the element is matching or not");
spyOn(spec, 'isExpectingTag');
});
@@ -27,7 +27,7 @@ describe("Cucumber.Ast.Filter.ElementMatchingTagSpec", function() {
expect(element.getTags).toHaveBeenCalled();
});
- it("checks wether the spec tag is expected or not", function() {
+ it("checks whether the spec tag is expected or not", function() {
spec.isMatching(element);
expect(spec.isExpectingTag).toHaveBeenCalled();
});
@@ -38,12 +38,12 @@ describe("Cucumber.Ast.Filter.ElementMatchingTagSpec", function() {
spyOn(_, 'any').andReturn(matchingElement);
});
- it("checks wether any of the element tags match the spec tag", function() {
+ it("checks whether any of the element tags match the spec tag", function() {
spec.isMatching(element);
expect(_.any).toHaveBeenCalledWith(elementTags, spec.isTagSatisfying);
});
- it("returns wether the element matched or not", function() {
+ it("returns whether the element matched or not", function() {
expect(spec.isMatching(element)).toBe(matchingElement);
});
});
@@ -54,12 +54,12 @@ describe("Cucumber.Ast.Filter.ElementMatchingTagSpec", function() {
spyOn(_, 'all').andReturn(matchingElement);
});
- it("checks wether any of the element tags match the spec tag", function() {
+ it("checks whether any of the element tags match the spec tag", function() {
spec.isMatching(element);
expect(_.all).toHaveBeenCalledWith(elementTags, spec.isTagSatisfying);
});
- it("returns wether the element matched or not", function() {
+ it("returns whether the element matched or not", function() {
expect(spec.isMatching(element)).toBe(matchingElement);
});
});
@@ -78,7 +78,7 @@ describe("Cucumber.Ast.Filter.ElementMatchingTagSpec", function() {
expect(checkedTag.getName).toHaveBeenCalled();
});
- it("checks wether the spec tag is expected or not on the element", function() {
+ it("checks whether the spec tag is expected or not on the element", function() {
spec.isTagSatisfying(checkedTag);
expect(spec.isExpectingTag).toHaveBeenCalled();
});