Skip to content

Commit

Permalink
added step_definition_path option
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdidit committed Jul 7, 2014
1 parent 8ca5b5c commit 197da23
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
10 changes: 9 additions & 1 deletion bin/peanut
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ __peanut__.options = nomnom.scriptName('peanut').opts({
position: 0,
list: true
},
step_definition_path: {
help: "Your step definitions path (default: features)",
default: ["features"],
abbr: "s",
position: 1,
list: true
},
output: {
help: "Specify a file to output JUnit compatible xml",
abbr: "o",
Expand Down Expand Up @@ -75,7 +82,8 @@ try {
__peanut__.envPath = path + env;
} catch(err) {
try {
env = '/features' + env;
path = process.cwd() + '/' +
__peanut__.options.path[0].split("/")[0];
fs.statSync(path + env);
__peanut__.envPath = path + env;
} catch(err) {
Expand Down
16 changes: 9 additions & 7 deletions lib/brain/parse_gherkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ var parseEnvFile = exports.parseEnvFile = function(callback) {

var parseStepDefinitions = exports.parseStepDefinitions = function() {
try {
_(findit.findSync(__peanut__.options.path[0])).each(function(file) {
if (file.match(/\_steps.js$/) !== null) {
var correctFilePath = process.cwd() + '/' + file;
delete require.cache[path.resolve(correctFilePath)];
require(correctFilePath);
}
});
_(__peanut__.options.step_definition_path).each(function(defPath) {
_(findit.findSync(defPath)).each(function(file) {
if (file.match(/\_steps.js$/) !== null) {
var correctFilePath = process.cwd() + '/' + file;
delete require.cache[path.resolve(correctFilePath)];
require(correctFilePath);
}
});
})
__peanut__.stepDefinitions = _(__peanut__.stepDefinitions).chain()
.flatten().unique().value();
} catch(err) { sys.puts(style.red(err)); }
Expand Down

0 comments on commit 197da23

Please sign in to comment.