Skip to content
Browse files

Initial commit.

  • Loading branch information...
1 parent 3126477 commit 3ecd4966a2c41ce4dfe4b9b124586502ca798765 @s9tpepper committed
Showing with 201 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 .npmignore
  3. +34 −0 README.md
  4. +9 −0 features/Testing.feature
  5. +27 −0 features/step_definitions/Testing_steps.js
  6. +37 −0 grunt.js
  7. +41 −0 package.json
  8. +51 −0 tasks/cucumber-js-task.js
View
1 .gitignore
@@ -1,3 +1,4 @@
.idea
*.iml
.DS_Store
+node_modules
View
1 .npmignore
@@ -0,0 +1 @@
+/node_modules/
View
34 README.md
@@ -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.
View
9 features/Testing.feature
@@ -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
View
27 features/step_definitions/Testing_steps.js
@@ -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;
View
37 grunt.js
@@ -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');
+
+};
View
41 package.json
@@ -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" : "s9tpepper@apache.org",
+ "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"
+ ]
+}
View
51 tasks/cucumber-js-task.js
@@ -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;
+ }
+ });
+
+ });
+
+};

0 comments on commit 3ecd496

Please sign in to comment.
Something went wrong with that request. Please try again.