Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add strict mode #204

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/cucumber/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ var Cli = function(argv) {
\n\
-v, --version Display Cucumber.js's version.\n\
\n\
-h, --help You're looking at it.\n");
-h, --help You're looking at it.\n\
\n\
-s, --strict Run will fail if it has pending steps.\n\
");
callback(true);
},

Expand Down
10 changes: 10 additions & 0 deletions lib/cucumber/cli/argument_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var ArgumentParser = function(argv) {
definitions[ArgumentParser.TAGS_OPTION_NAME] = [String, Array];
definitions[ArgumentParser.FORMAT_OPTION_NAME] = String;
definitions[ArgumentParser.HELP_FLAG_NAME] = Boolean;
definitions[ArgumentParser.STRICT_FLAG_NAME] = Boolean;
definitions[ArgumentParser.VERSION_FLAG_NAME] = Boolean;
definitions[ArgumentParser.COFFEE_SCRIPT_SNIPPETS_FLAG_NAME] = Boolean;
return definitions;
Expand All @@ -78,9 +79,15 @@ var ArgumentParser = function(argv) {
definitions[ArgumentParser.REQUIRE_OPTION_SHORT_NAME] = [ArgumentParser.LONG_OPTION_PREFIX + ArgumentParser.REQUIRE_OPTION_NAME];
definitions[ArgumentParser.FORMAT_OPTION_SHORT_NAME] = [ArgumentParser.LONG_OPTION_PREFIX + ArgumentParser.FORMAT_OPTION_NAME];
definitions[ArgumentParser.HELP_FLAG_SHORT_NAME] = [ArgumentParser.LONG_OPTION_PREFIX + ArgumentParser.HELP_FLAG_NAME];
definitions[ArgumentParser.STRICT_FLAG_SHORT_NAME] = [ArgumentParser.LONG_OPTION_PREFIX + ArgumentParser.STRICT_FLAG_NAME];
return definitions;
},

isStrictRequested: function isStrictRequested() {
var isStrictRequested = self.getOptionOrDefault(ArgumentParser.STRICT_FLAG_NAME, ArgumentParser.DEFAULT_STRICT_FLAG_VALUE);
return isStrictRequested;
},

isHelpRequested: function isHelpRequested() {
var isHelpRequested = self.getOptionOrDefault(ArgumentParser.HELP_FLAG_NAME, ArgumentParser.DEFAULT_HELP_FLAG_VALUE);
return isHelpRequested;
Expand Down Expand Up @@ -126,7 +133,10 @@ ArgumentParser.TAGS_OPTION_NAME = "tags";
ArgumentParser.TAGS_OPTION_SHORT_NAME = "t";
ArgumentParser.HELP_FLAG_NAME = "help";
ArgumentParser.HELP_FLAG_SHORT_NAME = "h";
ArgumentParser.STRICT_FLAG_NAME = "strict";
ArgumentParser.STRICT_FLAG_SHORT_NAME = "s";
ArgumentParser.DEFAULT_HELP_FLAG_VALUE = false;
ArgumentParser.DEFAULT_STRICT_FLAG_VALUE = false;
ArgumentParser.VERSION_FLAG_NAME = "version";
ArgumentParser.DEFAULT_VERSION_FLAG_VALUE = false;
ArgumentParser.COFFEE_SCRIPT_SNIPPETS_FLAG_NAME = "coffee";
Expand Down
5 changes: 5 additions & 0 deletions lib/cucumber/cli/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ var Configuration = function(argv) {
return isHelpRequested;
},

isStrictRequested: function isStrictRequested() {
var isStrictRequested = argumentParser.isStrictRequested();
return isStrictRequested;
},

isVersionRequested: function isVersionRequested() {
var isVersionRequested = argumentParser.isVersionRequested();
return isVersionRequested;
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var Runtime = function(configuration) {
throw new Error(Runtime.START_MISSING_CALLBACK_ERROR);
var features = self.getFeatures();
var supportCodeLibrary = self.getSupportCodeLibrary();
var astTreeWalker = Runtime.AstTreeWalker(features, supportCodeLibrary, listeners);
var astTreeWalker = Runtime.AstTreeWalker(features, supportCodeLibrary, listeners, configuration.isStrictRequested());
astTreeWalker.walk(callback);
},

Expand Down
10 changes: 8 additions & 2 deletions lib/cucumber/runtime/ast_tree_walker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var AstTreeWalker = function(features, supportCodeLibrary, listeners) {
var AstTreeWalker = function(features, supportCodeLibrary, listeners, strictMode) {
var Cucumber = require('../../cucumber');

var world;
Expand Down Expand Up @@ -154,7 +154,7 @@ var AstTreeWalker = function(features, supportCodeLibrary, listeners) {
},

didAllFeaturesSucceed: function didAllFeaturesSucceed() {
return allFeaturesSucceded;
return allFeaturesSucceded;
},

witnessFailedStep: function witnessFailedStep() {
Expand All @@ -163,10 +163,16 @@ var AstTreeWalker = function(features, supportCodeLibrary, listeners) {
},

witnessPendingStep: function witnessPendingStep() {
if (strictMode) {
allFeaturesSucceded = false;
}
skippingSteps = true;
},

witnessUndefinedStep: function witnessUndefinedStep() {
if (strictMode) {
allFeaturesSucceded = false;
}
skippingSteps = true;
},

Expand Down