features/extra/helpers.js
function(size, name) {
    var fs = require('fs');
    var path = require('path');
    name = this.uniqueName(name);
    // Cannot set this as a world property because the world
    // is cleaned up before the AfterFeatures hook is fired.
    var fixturePath = path.resolve('./features/extra/fixtures/tmp');
    if (!fs.existsSync(fixturePath)) fs.mkdirSync(fixturePath);
    var filename = path.join(fixturePath, name);
    var body;
    if (typeof size === 'string') {
      switch (size) {
        case 'empty': body = new Buffer(0); break;
        case 'small': body = new Buffer(1024 * 1024); break;
        case 'large': body = new Buffer(1024 * 1024 * 20); break;
      }
    } else if (typeof size === 'number') {
      body = new Buffer(size);
    }

    fs.writeFileSync(filename, body);
    return filename;
  }
function(size, name) {
    var fs = require('fs');
    var path = require('path');
    name = this.uniqueName(name);
    // Cannot set this as a world property because the world
    // is cleaned up before the AfterFeatures hook is fired.
    var fixturePath = path.resolve('./features/extra/fixtures/tmp');
    if (!fs.existsSync(fixturePath)) fs.mkdirSync(fixturePath);
    var filename = path.join(fixturePath, name);
    var body;
    if (typeof size === 'string') {
      switch (size) {
        case 'empty': body = new Buffer(0); break;
        case 'small': body = new Buffer(1024 * 1024); break;
        case 'large': body = new Buffer(1024 * 1024 * 20); break;
      }
    } else if (typeof size === 'number') {
      body = new Buffer(size);
    }

    fs.writeFileSync(filename, body);
    return filename;
  }
function ( size , name ) { var fs = require ( 'fs' ) ; var path = require ( 'path' ) ; name = this . uniqueName ( name ) ; // Cannot set this as a world property because the world // is cleaned up before the AfterFeatures hook is fired. var fixturePath = path . resolve ( './features/extra/fixtures/tmp' ) ; if ( ! fs . existsSync ( fixturePath ) ) fs . mkdirSync ( fixturePath ) ; var filename = path . join ( fixturePath , name ) ; var body ; if ( typeof size === 'string' ) { switch ( size ) { case 'empty' : body = new Buffer ( 0 ) ; break ; case 'small' : body = new Buffer ( 1024 * 1024 ) ; break ; case 'large' : body = new Buffer ( 1024 * 1024 * 20 ) ; break ; } } else if ( typeof size === 'number' ) { body = new Buffer ( size ) ; } fs . writeFileSync ( filename , body ) ; return filename ; }
Creates a fixture file of given size and returns the path.
Creates a fixture file of given size and returns the path .