code: function(action, gasToUse, timeOut) {
      timeOut = timeOut ? timeOut : 5000;
      var promise = new Promise(function(resolve, reject) {
          try {
            resolve(action());
          } catch (e) {
            reject(e);
          }
        })
        .then(function(txObject) {
          // We are in Geth
          console.log("Geth mode : run out of gas. throw expected ?");
          assert.equal(txObject.receipt.gasUsed, gasToUse, "should have used all the gas");
        })
        .catch(function(e) {
          if ((e + "").indexOf("invalid JUMP") > -1 || (e + "").indexOf("out of gas") > -1) {
            // We are in TestRPC
            console.log("TestRPC mode : invalid JUMP or out of gas detected")
          } else if ((e + "").indexOf("please check your gas amount") > -1) {
            // We are in Geth for a deployment
            console.log("Geth mode : deployment in progress ...")
          } else if ((e + "").indexOf("Error: VM Exception while processing transaction: invalid opcode") > -1) {
            //see issue : https://github.com/trufflesuite/truffle/issues/498
            console.log("TestRPC mode : Error: VM Exception. throw expected ?");
          } else {
            throw e;
          }
        });
  
      return promise;
    }
docs: From https://gist.github.com/xavierlepretre/d5583222fde52ddfbc58b7cfa0d2d0a9