-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
*.iml | ||
.DS_Store | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# grunt-cucumber-js | ||
|
||
A grunt.js task to run your cucumber.js feature suite. | ||
|
||
## Getting Started | ||
Install this grunt plugin next to your project's grunt.js gruntfile with: `npm install grunt-cucumber-js` | ||
|
||
Then add this line to your project's `grunt.js` gruntfile: | ||
|
||
```javascript | ||
grunt.initConfig({ | ||
cucumberjs: { | ||
features: "path/to/features", | ||
steps: "path/to/step_definitions", | ||
tags: "@dev" | ||
} | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-cucumber-js'); | ||
|
||
grunt.registerTask('default', 'cucumberjs'); | ||
``` | ||
|
||
## Bugs | ||
|
||
Help us squash them by submitting an issue that describes how you encountered it; please be as specific as possible including operating system, node, grunt, and grunt-contrib versions. | ||
|
||
## Release History | ||
|
||
see [CHANGELOG](/s9tpepper/grunt-cucumber-js/blob/master/CHANGELOG). | ||
|
||
## License | ||
Copyright (c) 2012 "s9tpepper" Omar Gonzalez & contributors. | ||
Licensed under the MIT license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Feature: Testing | ||
As a grunt-cucumber-js dev | ||
I want a Testing.feature file | ||
So that I can test the cucumber-js-task | ||
|
||
Scenario: A test scenario | ||
Given I have the number 1 and 3 | ||
When I add them together | ||
Then I should have 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function Testing_steps() { | ||
var firstNumber; | ||
var secondNumber; | ||
var sum = 0; | ||
|
||
this.Given(/^I have the number (\d+) and (\d+)$/, function(arg1, arg2, callback) { | ||
firstNumber = parseInt(arg1); | ||
secondNumber = parseInt(arg2); | ||
callback(); | ||
}); | ||
|
||
this.When(/^I add them together$/, function(callback) { | ||
sum = firstNumber + secondNumber; | ||
callback(); | ||
}); | ||
|
||
this.Then(/^I should have (\d+)$/, function(arg1, callback) { | ||
var expectedSum = parseInt(arg1); | ||
if (expectedSum !== sum) { | ||
throw new Error("It doesn't add up! " + arg1 + " !== " + sum); | ||
} | ||
callback(); | ||
}); | ||
|
||
}; | ||
|
||
module.exports = Testing_steps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module.exports = function (grunt) { | ||
'use strict'; | ||
|
||
grunt.initConfig({ | ||
lint: { | ||
all: ['grunt.js', 'tasks/*.js'] | ||
}, | ||
jshint: { | ||
options: { | ||
curly: true, | ||
eqeqeq: true, | ||
immed: true, | ||
latedef: true, | ||
newcap: true, | ||
noarg: true, | ||
sub: true, | ||
undef: true, | ||
boss: true, | ||
eqnull: true, | ||
node: true, | ||
es5: true | ||
}, | ||
globals: {} | ||
}, | ||
cucumberjs: { | ||
features: "features", | ||
steps: "features/step_definitions" | ||
} | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-contrib'); | ||
|
||
grunt.loadTasks("tasks"); | ||
|
||
grunt.registerTask('default', 'lint cucumberjs'); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name" : "grunt-cucumber", | ||
"description" : "Grunt task for running Cucumber.js", | ||
"version" : "0.1.0", | ||
"homepage" : "https://github.com/s9tpepper/grunt-cucumber-js", | ||
"author" : { | ||
"name" : "Omar Gonzalez", | ||
"email" : "[email protected]", | ||
"url" : "http://omar.likesflex.com" | ||
}, | ||
"repository" : { | ||
"type" : "git", | ||
"url" : "git://github.com/s9tpepper/grunt-cucumber-js.git" | ||
}, | ||
"bugs" : { | ||
"url" : "https://github.com/s9tpepper/grunt-cucumber-js/issues" | ||
}, | ||
"licenses" : [ | ||
{ | ||
"type" : "MIT", | ||
"url" : "https://github.com/s9tpepper/grunt-cucumber-js/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"main" : "grunt.js", | ||
"bin" : "bin/grunt-cucumber", | ||
"engines" : { | ||
"node" : "*" | ||
}, | ||
"scripts" : { | ||
}, | ||
"dependencies" : { | ||
}, | ||
"devDependencies" : { | ||
"grunt" : "~0.3.9", | ||
"grunt-contrib": "~0.1.4", | ||
"cucumber": "~0.2.19" | ||
}, | ||
"keywords" : [ | ||
"gruntplugin" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module.exports = function (grunt) { | ||
|
||
grunt.registerTask("cucumberjs", "Runs cucumber.js", function () { | ||
|
||
var Cucumber = require('cucumber'); | ||
|
||
var features = grunt.config("cucumberjs.features") || 'features'; | ||
var steps = grunt.config("cucumberjs.steps") || 'features/step_definitions'; | ||
var tags = grunt.config("cucumberjs.tags") || '~@Pending'; | ||
|
||
var options = [ 'node', | ||
'cucumber-js-task.js', | ||
features, | ||
'-r', | ||
steps, | ||
'-t', | ||
tags ]; | ||
|
||
var cli = Cucumber.Cli(options); | ||
|
||
var done = this.async(); | ||
cli.run(function(succeeded) { | ||
var code = succeeded ? 0 : 1; | ||
var exitFunction = function() { | ||
if (code !== 0) { | ||
process.exit(code); | ||
} else { | ||
done(); | ||
} | ||
}; | ||
|
||
// --- exit after waiting for all pending output --- | ||
var waitingIO = false; | ||
process.stdout.on('drain', function() { | ||
if (waitingIO) { | ||
// the kernel buffer is now empty | ||
exitFunction(); | ||
} | ||
}); | ||
if (process.stdout.write("")) { | ||
// no buffer left, exit now: | ||
exitFunction(); | ||
} else { | ||
// write() returned false, kernel buffer is not empty yet... | ||
waitingIO = true; | ||
} | ||
}); | ||
|
||
}); | ||
|
||
}; |