Permalink
Browse files

Add argument parser specs for --coffee option

  • Loading branch information...
1 parent 38f5600 commit 5ff71bb72d3962ff270970c0c9aa98bff9e15374 @jbpros jbpros committed Dec 25, 2012
Showing with 46 additions and 28 deletions.
  1. +1 −1 lib/cucumber/cli.js
  2. +27 −27 lib/cucumber/cli/argument_parser.js
  3. +18 −0 spec/cucumber/cli/argument_parser_spec.js
View
@@ -65,7 +65,7 @@ var Cli = function(argv) {
summary : prints a summary only, after all\n\
scenarios were executed\n\
\n\
---coffee Display step definitions in CoffeeScript.\n\
+--coffee Display step definitions snippets in CoffeeScript.\n\
\n\
-v, --version Display Cucumber.js's version.\n\
\n\
@@ -64,12 +64,12 @@ var ArgumentParser = function(argv) {
getKnownOptionDefinitions: function getKnownOptionDefinitions() {
var definitions = {};
- definitions[ArgumentParser.REQUIRE_OPTION_NAME] = [path, Array];
- definitions[ArgumentParser.TAGS_OPTION_NAME] = [String, Array];
- definitions[ArgumentParser.FORMAT_OPTION_NAME] = String;
- definitions[ArgumentParser.HELP_FLAG_NAME] = Boolean;
- definitions[ArgumentParser.VERSION_FLAG_NAME] = Boolean;
- definitions[ArgumentParser.COFFEE_SNIPPETS] = Boolean;
+ definitions[ArgumentParser.REQUIRE_OPTION_NAME] = [path, Array];
+ definitions[ArgumentParser.TAGS_OPTION_NAME] = [String, Array];
+ definitions[ArgumentParser.FORMAT_OPTION_NAME] = String;
+ definitions[ArgumentParser.HELP_FLAG_NAME] = Boolean;
+ definitions[ArgumentParser.VERSION_FLAG_NAME] = Boolean;
+ definitions[ArgumentParser.COFFEE_SCRIPT_SNIPPETS_FLAG_NAME] = Boolean;
return definitions;
},
@@ -91,9 +91,9 @@ var ArgumentParser = function(argv) {
return isVersionRequested;
},
- shouldSnippetsBeInCoffee: function shouldSnippetsBeInCoffee() {
- var coffeeDisplay = self.getOptionOrDefault(ArgumentParser.COFFEE_SNIPPETS, ArgumentParser.DEFAULT_COFFEE_SNIPPETS);
- return coffeeDisplay;
+ shouldSnippetsBeInCoffeeScript: function shouldSnippetsBeInCoffeeScript() {
+ var areSnippetsInCoffeeScript = self.getOptionOrDefault(ArgumentParser.COFFEE_SCRIPT_SNIPPETS_FLAG_NAME, ArgumentParser.DEFAULT_COFFEE_SCRIPT_SNIPPETS_FLAG_VALUE);
+ return areSnippetsInCoffeeScript;
},
storeOptions: function storeOptions(newOptions) {
@@ -112,24 +112,24 @@ var ArgumentParser = function(argv) {
};
return self;
};
-ArgumentParser.NUMBER_OF_LEADING_ARGS_TO_SLICE = 2;
-ArgumentParser.DEFAULT_FEATURES_DIRECTORY = "features";
-ArgumentParser.FEATURE_FILENAME_REGEXP = /[\/\\][^\/\\]+\.feature$/i;
-ArgumentParser.LONG_OPTION_PREFIX = "--";
-ArgumentParser.REQUIRE_OPTION_NAME = "require";
-ArgumentParser.REQUIRE_OPTION_SHORT_NAME = "r";
-ArgumentParser.FORMAT_OPTION_NAME = "format";
-ArgumentParser.FORMAT_OPTION_SHORT_NAME = "f";
-ArgumentParser.DEFAULT_FORMAT_VALUE = "progress";
-ArgumentParser.TAGS_OPTION_NAME = "tags";
-ArgumentParser.TAGS_OPTION_SHORT_NAME = "t";
-ArgumentParser.HELP_FLAG_NAME = "help";
-ArgumentParser.HELP_FLAG_SHORT_NAME = "h";
-ArgumentParser.DEFAULT_HELP_FLAG_VALUE = false;
-ArgumentParser.VERSION_FLAG_NAME = "version";
-ArgumentParser.DEFAULT_VERSION_FLAG_VALUE = false;
-ArgumentParser.COFFEE_SNIPPETS = "coffee";
-ArgumentParser.DEFAULT_COFFEE_SNIPPETS = false;
+ArgumentParser.NUMBER_OF_LEADING_ARGS_TO_SLICE = 2;
+ArgumentParser.DEFAULT_FEATURES_DIRECTORY = "features";
+ArgumentParser.FEATURE_FILENAME_REGEXP = /[\/\\][^\/\\]+\.feature$/i;
+ArgumentParser.LONG_OPTION_PREFIX = "--";
+ArgumentParser.REQUIRE_OPTION_NAME = "require";
+ArgumentParser.REQUIRE_OPTION_SHORT_NAME = "r";
+ArgumentParser.FORMAT_OPTION_NAME = "format";
+ArgumentParser.FORMAT_OPTION_SHORT_NAME = "f";
+ArgumentParser.DEFAULT_FORMAT_VALUE = "progress";
+ArgumentParser.TAGS_OPTION_NAME = "tags";
+ArgumentParser.TAGS_OPTION_SHORT_NAME = "t";
+ArgumentParser.HELP_FLAG_NAME = "help";
+ArgumentParser.HELP_FLAG_SHORT_NAME = "h";
+ArgumentParser.DEFAULT_HELP_FLAG_VALUE = false;
+ArgumentParser.VERSION_FLAG_NAME = "version";
+ArgumentParser.DEFAULT_VERSION_FLAG_VALUE = false;
+ArgumentParser.COFFEE_SCRIPT_SNIPPETS_FLAG_NAME = "coffee";
+ArgumentParser.DEFAULT_COFFEE_SCRIPT_SNIPPETS_FLAG_VALUE = false;
ArgumentParser.FeaturePathExpander = require('./argument_parser/feature_path_expander');
ArgumentParser.PathExpander = require('./argument_parser/path_expander');
ArgumentParser.SupportCodePathExpander = require('./argument_parser/support_code_path_expander');
@@ -339,6 +339,24 @@ describe("Cucumber.Cli.ArgumentParser", function () {
});
});
+ describe("shouldSnippetsBeInCoffeeScript()", function () {
+ var shouldSnippetsBeInCoffeeScript;
+
+ beforeEach(function () {
+ shouldSnippetsBeInCoffeeScript = createSpy("should snippets be in coffee script?");
+ spyOn(argumentParser, 'getOptionOrDefault').andReturn(shouldSnippetsBeInCoffeeScript);
+ });
+
+ it("gets the 'coffee' flag with a falsy default value", function () {
+ argumentParser.shouldSnippetsBeInCoffeeScript();
+ expect(argumentParser.getOptionOrDefault).toHaveBeenCalledWith("coffee", false);
+ });
+
+ it("returns the flag value", function () {
+ expect(argumentParser.shouldSnippetsBeInCoffeeScript()).toBe(shouldSnippetsBeInCoffeeScript);
+ });
+ });
+
describe("getOptions() [storeOptions()]", function () {
var options;

0 comments on commit 5ff71bb

Please sign in to comment.