tasks/behat.js
function behatRunner(data, callback) {

    var spawn = require('child_process').spawn,
    behat     = spawn(data.cmd, data.args),
    stderr    = '',
    stdout    = '',
    options   = data.options || {};

    if(typeof options.failOnUndefined === 'undefined') {
      options.failOnUndefined = false;
    }
    if(typeof options.failOnFailed === 'undefined') {
      options.failOnFailed = true;
    }

    behat.stdout.on('data', function (data) {
      stdout += data;
    });

    behat.stderr.on('data', function (data) {
      stderr += data;
    });

    behat.on('exit', function (code) {
      if (code === 127) {
        grunt.log.errorlns(
          'In order for this task to work properly, Behat must be ' +
          'installed and in the system PATH (if you can run "behat" at' +
          ' the command line, this task should work). Unfortunately, ' +
          'Behat cannot be installed automatically via npm or grunt. ' +
          'See the Behat installation instructions: ' +
          'http://docs.behat.org/quick_intro.html#installation'
        );
        grunt.warn('Behat not found.', code);
      }
      else {
        if(options.failOnUndefined && hasUndefinedSteps(stdout)) {
          grunt.verbose.writeln(stdout);
          stderr = 'Undefined Steps';
          if(options.output) {
            stderr = stdout;
          }
        }
        if(options.failOnFailed && hasFailedSteps(stdout)) {
          grunt.verbose.writeln(stdout);
          stderr = 'Failed Steps';
          if(options.output) {
            stderr = stdout;
          }
        }
        if (stderr === '' && options.output) {
            grunt.log.write(stdout);
        }
      }
      callback(stderr, stdout);
    });

  }
function behatRunner(data, callback) {

    var spawn = require('child_process').spawn,
    behat     = spawn(data.cmd, data.args),
    stderr    = '',
    stdout    = '',
    options   = data.options || {};

    if(typeof options.failOnUndefined === 'undefined') {
      options.failOnUndefined = false;
    }
    if(typeof options.failOnFailed === 'undefined') {
      options.failOnFailed = true;
    }

    behat.stdout.on('data', function (data) {
      stdout += data;
    });

    behat.stderr.on('data', function (data) {
      stderr += data;
    });

    behat.on('exit', function (code) {
      if (code === 127) {
        grunt.log.errorlns(
          'In order for this task to work properly, Behat must be ' +
          'installed and in the system PATH (if you can run "behat" at' +
          ' the command line, this task should work). Unfortunately, ' +
          'Behat cannot be installed automatically via npm or grunt. ' +
          'See the Behat installation instructions: ' +
          'http://docs.behat.org/quick_intro.html#installation'
        );
        grunt.warn('Behat not found.', code);
      }
      else {
        if(options.failOnUndefined && hasUndefinedSteps(stdout)) {
          grunt.verbose.writeln(stdout);
          stderr = 'Undefined Steps';
          if(options.output) {
            stderr = stdout;
          }
        }
        if(options.failOnFailed && hasFailedSteps(stdout)) {
          grunt.verbose.writeln(stdout);
          stderr = 'Failed Steps';
          if(options.output) {
            stderr = stdout;
          }
        }
        if (stderr === '' && options.output) {
            grunt.log.write(stdout);
        }
      }
      callback(stderr, stdout);
    });

  }
========================================================================== HELPERS ==========================================================================