<commit_before>/*
 * installed-test.js: Tests for working with installed modules with quill.
 *
 * (C) 2010, Nodejitsu Inc.
 *
 */

var assert = require('assert'),
    fs = require('fs'),
    path = require('path'),
    common = require('flatiron').common,
    rimraf = common.rimraf,
    nock = require('nock'),
    vows = require('vows'),
    helpers = require('../helpers'),
    macros = require('../helpers/macros'),
    mock = require('../helpers/mock'),
    quill = require('../../lib/quill');

var fixturesDir = path.join(__dirname, '..', 'fixtures'),
    systemsDir = path.join(fixturesDir, 'systems'),
    installDir = path.join(fixturesDir, 'installed'),
    sourceDir = path.join(systemsDir, 'tgz');

function assertInstalled(system) {
  assert.isString(system.path);
  assert.isTrue(path.existsSync(system.path));
  assert.isTrue(path.existsSync(path.join(system.path, 'system.json')));
  
  var details = helpers.latestHistory(system, 1);
  
  assert.deepEqual(details.history[details.keys[0]], {
    version: system.version,
    action: 'copy'
  });
}

function assertUninstalled(name) {
  assert.isTrue(path.existsSync(path.join(installDir, name)));
  assert.isFalse(path.existsSync(path.join(installDir, name, '0.0.0')));
}

vows.describe('quill/composer/installed').addBatch(
  macros.shouldInit(function () {
    try {
      rimraf.sync(installDir);
    }
    catch (ex) {
      console.dir(ex);
    }
    <commit_msg>[fix test] Dont delete the `.gitkeep` file(s)<commit_after>/*
 * installed-test.js: Tests for working with installed modules with quill.
 *
 * (C) 2010, Nodejitsu Inc.
 *
 */

var assert = require('assert'),
    fs = require('fs'),
    path = require('path'),
    common = require('flatiron').common,
    rimraf = common.rimraf,
    nock = require('nock'),
    vows = require('vows'),
    helpers = require('../helpers'),
    macros = require('../helpers/macros'),
    mock = require('../helpers/mock'),
    quill = require('../../lib/quill');

var fixturesDir = path.join(__dirname, '..', 'fixtures'),
    systemsDir = path.join(fixturesDir, 'systems'),
    installDir = path.join(fixturesDir, 'installed'),
    sourceDir = path.join(systemsDir, 'tgz');

function assertInstalled(system) {
  assert.isString(system.path);
  assert.isTrue(path.existsSync(system.path));
  assert.isTrue(path.existsSync(path.join(system.path, 'system.json')));
  
  var details = helpers.latestHistory(system, 1);
  
  assert.deepEqual(details.history[details.keys[0]], {
    version: system.version,
    action: 'copy'
  });
}

function assertUninstalled(name) {
  assert.isTrue(path.existsSync(path.join(installDir, name)));
  assert.isFalse(path.existsSync(path.join(installDir, name, '0.0.0')));
}

vows.describe('quill/composer/installed').addBatch(
  macros.shouldInit(function () {
    try {
      fs.readdirSync(installDir)
        .filter(function (file) {
          return file !== '.gitkeep'
        })
        .forEach(function (file) {
          rimraf.sync(path.join(installDir, file));
        });
    }
    catch (ex) {
      console.dir(ex);
    }
    
{'fraction_non_alphanumeric': 0.17589893100097181, 'fraction_numerical': 0.0058309037900874635, 'mean_word_length': 3.534508076358297, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3690590', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1016, 'n_words': 173}