From 899ec6a6c68ee4b9c27b6c9061ea682c535cf66a Mon Sep 17 00:00:00 2001 From: Jake Bixby Date: Thu, 8 Oct 2015 17:46:35 -0700 Subject: [PATCH] removed helpers now provided by ember-cli-internal-test-helpers --- blueprints/blueprint-test/index.js | 1 + lib/helpers/assert-file.js | 100 ----------------------------- lib/helpers/assert.js | 8 --- lib/helpers/blueprint-helper.js | 4 +- lib/helpers/ember.js | 29 --------- lib/helpers/project-init.js | 2 +- lib/helpers/project-setup.js | 2 +- lib/helpers/setup.js | 4 +- package.json | 1 + 9 files changed, 8 insertions(+), 143 deletions(-) delete mode 100644 lib/helpers/assert-file.js delete mode 100644 lib/helpers/assert.js delete mode 100644 lib/helpers/ember.js diff --git a/blueprints/blueprint-test/index.js b/blueprints/blueprint-test/index.js index a8599f1..e827554 100644 --- a/blueprints/blueprint-test/index.js +++ b/blueprints/blueprint-test/index.js @@ -15,6 +15,7 @@ module.exports = { afterInstall: function() { return Promise.all([ this.addPackageToProject('ember-cli-blueprint-test-helpers', '^1.0.0'), + this.addPackageToProject('ember-cli-internal-test-helpers', '^1.0.0'), this.addPackageToProject('glob', '5.0.13'), this.addPackageToProject('mocha', '^2.2.1') ]); diff --git a/lib/helpers/assert-file.js b/lib/helpers/assert-file.js deleted file mode 100644 index 4cccbdd..0000000 --- a/lib/helpers/assert-file.js +++ /dev/null @@ -1,100 +0,0 @@ -'use strict'; - -var expect = require('chai').expect; -var flatten = require('lodash/array/flatten'); -var contains = require('lodash/collection/contains'); -var fs = require('fs-extra'); -var path = require('path'); -var EOL = require('os').EOL; -var existsSync = require('exists-sync'); - -//TODO: Remove this after assertions have been extracted to separate library -/* - Asserts that a given file exists. - - ```js - assertFile('some/file.js'); - ``` - - You can also make assertions about the file’s contents using - `contains` and `doesNotContain`: - - ```js - assertFile('some/file.js', { - contains: [ - 'foo', - /[0-9]+/ - ], - doesNotContain: 'bar' - }); - ``` - - @method assertFile - @param {String} file - @param {Object} options - Optional extra assertions to perform on the file. - @param {String, Array} options.contains - Strings or regular expressions the file must contain. - @param {String, Array} options.doesNotContain - Strings or regular expressions the file must *not* contain. -*/ -module.exports = function assertFile(file, options) { - var filePath = path.join(process.cwd(), file); - expect(existsSync(filePath)).to.equal(true, 'expected ' + file + ' to exist'); - - if (!options) { - return; - } - - var actual = fs.readFileSync(filePath, { encoding: 'utf-8' }); - if (options.contains) { - flatten([options.contains]).forEach(function(expected) { - var pass; - - if (expected.test) { - pass = expected.test(actual); - } else { - pass = contains(actual, expected); - } - - var message = 'expected: `' + file + '`'; - if (pass) { - expect(true).to.equal(true, EOL + EOL + 'expected ' + file + ':' + EOL + EOL + - actual + - EOL + 'to contain:' + EOL + EOL + - expected + EOL); - } else { - throw new EqualityError(message, actual, expected); - } - }); - } - - if (options.doesNotContain) { - flatten([options.doesNotContain]).forEach(function(unexpected) { - var pass; - - if (unexpected.test) { - pass = !unexpected.test(actual); - } else { - pass = !contains(actual, unexpected); - } - - expect(pass).to.equal(true, EOL + EOL + 'expected ' + file + ':' + EOL + EOL + - actual + EOL + - 'not to contain:' + EOL + EOL + - unexpected + EOL); - }); - } -}; - -function EqualityError(message, actual, expected) { - this.message = message; - this.actual = actual; - this.expected = expected; - this.showDiff = true; - Error.captureStackTrace(this, module.exports); -} - -EqualityError.prototype = Object.create(Error.prototype); -EqualityError.prototype.name = 'EqualityError'; -EqualityError.prototype.constructor = EqualityError; diff --git a/lib/helpers/assert.js b/lib/helpers/assert.js deleted file mode 100644 index 1a60f38..0000000 --- a/lib/helpers/assert.js +++ /dev/null @@ -1,8 +0,0 @@ -var chai = require('chai'); -var chaiAsPromised = require('chai-as-promised'); - -chai.use(chaiAsPromised); - -module.exports = chai.assert; - -//TODO: Remove this after assertions have been extracted to separate library \ No newline at end of file diff --git a/lib/helpers/blueprint-helper.js b/lib/helpers/blueprint-helper.js index 7f0234a..6874d8f 100644 --- a/lib/helpers/blueprint-helper.js +++ b/lib/helpers/blueprint-helper.js @@ -1,13 +1,13 @@ 'use strict'; -var ember = require('./ember'); +var ember = require('ember-cli-internal-test-helpers/lib/helpers/ember'); var Promise = require('ember-cli/lib/ext/promise'); var initProject = require('./project-init'); var path = require('path'); var expect = require('chai').expect; var existsSync = require('exists-sync'); var walkSync = require('walk-sync'); -var assertFile = require('./assert-file'); +var assertFile = require('ember-cli-internal-test-helpers/lib/helpers/assert-file'); var tmpenv = require('./tmp-env'); /** diff --git a/lib/helpers/ember.js b/lib/helpers/ember.js deleted file mode 100644 index 4e0fe16..0000000 --- a/lib/helpers/ember.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -var MockUI = require('ember-cli/tests/helpers/mock-ui'); -var MockAnalytics = require('ember-cli/tests/helpers/mock-analytics'); -var Cli = require('ember-cli/lib/cli'); -var path = require('path'); - -module.exports = function ember(args) { - var cli; - - args.push('--disable-analytics'); - args.push('--watcher=node'); - cli = new Cli({ - inputStream: [], - outputStream: [], - cliArgs: args, - Leek: MockAnalytics, - UI: MockUI, - testing: true, - cli: { - name: 'my-app', - npmPackage: 'ember-cli', - // SUPERHAX.biz.gov - root: path.resolve(__dirname, '..', '..', 'node_modules', 'ember-cli') - } - }); - - return cli; -}; diff --git a/lib/helpers/project-init.js b/lib/helpers/project-init.js index 32c265a..6aa4c1e 100644 --- a/lib/helpers/project-init.js +++ b/lib/helpers/project-init.js @@ -1,6 +1,6 @@ 'use strict'; -var ember = require('./ember'); +var ember = require('ember-cli-internal-test-helpers/lib/helpers/ember'); var Promise = require('ember-cli/lib/ext/promise'); var setupPodConfig = require('./project-setup').setupPodConfig; diff --git a/lib/helpers/project-setup.js b/lib/helpers/project-setup.js index a6c3f4f..998bdb8 100644 --- a/lib/helpers/project-setup.js +++ b/lib/helpers/project-setup.js @@ -1,7 +1,7 @@ 'use strict'; var Promise = require('ember-cli/lib/ext/promise'); -var replaceFile = require('ember-cli/tests/helpers/file-utils').replaceFile; +var replaceFile = require('ember-cli-internal-test-helpers/lib/helpers/file-utils').replaceFile; var EOL = require('os').EOL; module.exports.setupPodConfig = function(options) { diff --git a/lib/helpers/setup.js b/lib/helpers/setup.js index f59e1b9..d76fd3a 100644 --- a/lib/helpers/setup.js +++ b/lib/helpers/setup.js @@ -1,8 +1,8 @@ 'use strict'; var Promise = require('ember-cli/lib/ext/promise'); -var conf = require('ember-cli/tests/helpers/conf'); -var BlueprintNpmTask = require('ember-cli/tests/helpers/disable-npm-on-blueprint'); +var conf = require('ember-cli-internal-test-helpers/lib/helpers/conf'); +var BlueprintNpmTask = require('ember-cli-internal-test-helpers/lib/helpers/disable-npm-on-blueprint'); var fs = require('fs-extra'); var remove = Promise.denodeify(fs.remove); var tmpenv = require('./tmp-env'); diff --git a/package.json b/package.json index bccc92f..e087667 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "author": "Jake Bixby", "license": "MIT", "dependencies": { + "ember-cli-internal-test-helpers": "^0.2.0", "chai": "^3.3.0", "chai-as-promised": "^5.1.0", "ember-cli": "^1.13.8",