function request(svc, operation, params, next, extra) {
    var world = this;

    if (!svc) svc = this.service;
    if (typeof svc === 'string') svc = this[svc];

    svc[operation](params, function(err, data) {
      world.response = this;
      world.error = err;
      world.data = data;

      try {
        if (typeof next.condition === 'function') {
          var condition = next.condition.call(world, world);
          if (!condition) {
            next.fail(new Error('Request success condition failed'));
            return;
          }
        }

        if (extra) {
          extra.call(world, world.response);
          next.call(world);
        }
        else if (extra !== false && err) {
          world.unexpectedError(world.response, next);
        } else {
          next.call(world);
        }
      } catch (err) {
        next.fail(err);
      }
    });
  }
function request(svc, operation, params, next, extra) {
    var world = this;

    if (!svc) svc = this.service;
    if (typeof svc === 'string') svc = this[svc];

    svc[operation](params, function(err, data) {
      world.response = this;
      world.error = err;
      world.data = data;

      try {
        if (typeof next.condition === 'function') {
          var condition = next.condition.call(world, world);
          if (!condition) {
            next.fail(new Error('Request success condition failed'));
            return;
          }
        }

        if (extra) {
          extra.call(world, world.response);
          next.call(world);
        }
        else if (extra !== false && err) {
          world.unexpectedError(world.response, next);
        } else {
          next.call(world);
        }
      } catch (err) {
        next.fail(err);
      }
    });
  }
function request ( svc , operation , params , next , extra ) { var world = this ; if ( ! svc ) svc = this . service ; if ( typeof svc === 'string' ) svc = this [ svc ] ; svc [ operation ] ( params , function ( err , data ) { world . response = this ; world . error = err ; world . data = data ; try { if ( typeof next . condition === 'function' ) { var condition = next . condition . call ( world , world ) ; if ( ! condition ) { next . fail ( new Error ( 'Request success condition failed' ) ) ; return ; } } if ( extra ) { extra . call ( world , world . response ) ; next . call ( world ) ; } else if ( extra !== false && err ) { world . unexpectedError ( world . response , next ) ; } else { next . call ( world ) ; } } catch ( err ) { next . fail ( err ) ; } } ) ; }
A short-cut for calling a service operation and waiting for it to
finish execution before moving onto the next step in the scenario.
A short - cut for calling a service operation and waiting for it to finish execution before moving onto the next step in the scenario .
request function