Sha256: c7001838a0b28e7e9cd156e76ca195e951a196c6a099bf00c04afdac53ca413a
Contents?: true
Size: 1.54 KB
Versions: 19
Compression:
Stored size: 1.54 KB
Contents
'use strict'; var Fs = require('fs'); var Assert = require('assert'); var Helper = module.exports = {}; Helper.SANDBOX_DIR = require('fs').realpathSync(__dirname + '/..') + '/tmp/sandbox'; var fns2type = { isFile: 'file', isDirectory: 'directory', isBlockDevice: 'block device', isCharacterDevice: 'character device', isSymbolicLink: 'symlink', isFIFO: 'FIFO', isSocket: 'socket' }; function getPathType(stats) { var fn; if (!stats || 'object' !== typeof stats) { throw new Error('Stats object required'); } /*jslint forin:true*/ for (fn in fns2type) { if ('function' === typeof stats[fn] && stats[fn]()) { return fns2type[fn]; } } throw new Error('Expected valid stats object'); } Object.getOwnPropertyNames(fns2type).forEach(function (fn) { Assert[fn] = function (stats, msg) { var expected = fns2type[fn], result = getPathType(stats); msg = msg || 'Expected `' + expected + '` but got `' + result + '`.'; Assert.ok(expected === result, msg); }; }); Assert.hasPermsMode = function hasPermsMode(stats, expected, msg) { var result = stats.mode.toString(8).slice(-4); msg = msg || 'Expected `' + expected + '` mode, but got `' + result + '`.'; Assert.ok(expected === result, msg); }; Assert.pathExists = function pathExists(path, msg) { msg = msg || 'Expect path `' + path + '` to exist.'; Assert.ok(Fs.existsSync(path), msg); }; Assert.pathNotExists = function pathNotExists(path, msg) { msg = msg || 'Does not expect path `' + path + '` to exist.'; Assert.ok(!Fs.existsSync(path), msg); };
Version data entries
19 entries across 19 versions & 1 rubygems