Skip to content

Commit

Permalink
Fix tests, update yeoman-generator
Browse files Browse the repository at this point in the history
Updated to use the JSONFileContent function in yeoman-assert for
checking package.json.

Also updated the syntax in the default generator so it works with the
new version of yeoman-generator.
  • Loading branch information
sondr3 committed May 27, 2016
1 parent fa9e6b1 commit 19ea966
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 80 deletions.
15 changes: 3 additions & 12 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
var _ = require('lodash');
var chalk = require('chalk');
var generators = require('yeoman-generator');
var yosay = require('yosay');
var shelljs = require('shelljs');

module.exports = generators.Base.extend({
Expand Down Expand Up @@ -32,13 +31,7 @@ module.exports = generators.Base.extend({
},

prompting: function () {
var done = this.async();

if (!this.options['skip-welcome-message']) {
this.log(yosay('\'Allo \'allo!'));
}

var prompts = [{
var questions = [{
name: 'projectName',
message: 'What is the name of your project?',
store: true
Expand Down Expand Up @@ -93,10 +86,8 @@ module.exports = generators.Base.extend({
store: true
}];

this.prompt(prompts, function (props) {
this.props = _.extend(this.props, props);

done();
return this.prompt(questions).then(function (props) {
this.props = props;
}.bind(this));
},

Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"lodash": "^4.11.1",
"shelljs": "^0.7.0",
"yargs": "^4.6.0",
"yeoman-generator": "^0.23.3",
"yosay": "^1.1.1"
"yeoman-generator": "^0.23.3"
},
"devDependencies": {
"ava": "^0.14.0",
Expand All @@ -38,6 +37,9 @@
},
"xo": {
"space": true,
"rules": {
"new-cap": 0
},
"ignores": [
"generators/app/templates/**",
"generators/boilerplate/templates/**",
Expand Down
70 changes: 35 additions & 35 deletions test/gulp.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ test('creates package.json', () => {
});

test('package.json contains correct packages', () => {
[
'"autoprefixer": "^6.2.3"',
'"browser-sync": "^2.11.0"',
'"del": "^2.2.0"',
'"gulp": "git://github.com/gulpjs/gulp.git#4.0"',
'"gulp-cache": "^0.4.1"',
'"gulp-concat": "^2.6.0"',
'"gulp-cssnano": "^2.1.0"',
'"gulp-eslint": "^2.0.0"',
'"gulp-gzip": "^1.1.0"',
'"gulp-htmlmin": "^1.3.0"',
'"gulp-if": "^2.0.0"',
'"gulp-imagemin": "^2.1.0"',
'"gulp-inject": "^4.0.0"',
'"gulp-load-plugins": "^1.2.0"',
'"gulp-newer": "^1.1.0"',
'"gulp-postcss": "^6.0.0"',
'"gulp-rename": "^1.2.2"',
'"gulp-rev": "^7.0.0"',
'"gulp-sass": "^2.1.1"',
'"gulp-size": "^2.0.0"',
'"gulp-sourcemaps": "^1.3.0"',
'"gulp-uglify": "^1.5.1"',
'"gulp-uncss": "^1.0.0"',
'"shelljs": "^0.6.0"',
'"yargs": "^4.3.2"'
].forEach(pack => {
assert.fileContent('package.json', pack);
assert.JSONFileContent('package.json', {
devDependencies: {
'autoprefixer': '^6.2.3',
'browser-sync': '^2.11.0',
'del': '^2.2.0',
'gulp': 'git://github.com/gulpjs/gulp.git#4.0',
'gulp-cache': '^0.4.1',
'gulp-concat': '^2.6.0',
'gulp-cssnano': '^2.1.0',
'gulp-eslint': '^2.0.0',
'gulp-gzip': '^1.1.0',
'gulp-htmlmin': '^1.3.0',
'gulp-if': '^2.0.0',
'gulp-imagemin': '^2.1.0',
'gulp-inject': '^4.0.0',
'gulp-load-plugins': '^1.2.0',
'gulp-newer': '^1.1.0',
'gulp-postcss': '^6.0.0',
'gulp-rename': '^1.2.2',
'gulp-rev': '^7.0.0',
'gulp-sass': '^2.1.1',
'gulp-size': '^2.0.0',
'gulp-sourcemaps': '^1.3.0',
'gulp-uglify': '^1.5.1',
'gulp-uncss': '^1.0.0',
'shelljs': '^0.6.0',
'yargs': '^4.3.2'
}
});
});

Expand All @@ -58,13 +58,13 @@ test('does not create credentials files', () => {
});

test('does not contain uploading packages', () => {
[
'"gulp-awspublish"',
'"concurrent-transform"',
'"gulp-rsync"',
'"gulp-gh-pages"'
].forEach(pack => {
assert.noFileContent('package.json', pack);
assert.noJSONFileContent('package.json', {
devDependencies: {
'gulp-awspublish': '^3.0.1',
'concurrent-transform': '^1.0.0',
'gulp-rsync': '^0.0.5',
'gulp-gh-pages': '^0.5.2'
}
});
});

Expand Down
20 changes: 10 additions & 10 deletions test/uploading/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ test('creates package.json file', () => {
});

test('contain correct uploading packages', () => {
[
'"gulp-awspublish": "^3.0.1"',
'"concurrent-transform": "^1.0.0"'
].forEach(pack => {
assert.fileContent('package.json', pack);
assert.JSONFileContent('package.json', {
devDependencies: {
'gulp-awspublish': '^3.0.1',
'concurrent-transform': '^1.0.0'
}
});
});

test('does not contain wrong uploading packages', () => {
[
'"gulp-rsync"',
'"gulp-gh-pages"'
].forEach(pack => {
assert.noFileContent('package.json', pack);
assert.noJSONFileContent('package.json', {
devDependencies: {
'gulp-rsync': '^0.0.5',
'gulp-gh-pages': '^0.5.2'
}
});
});

Expand Down
18 changes: 11 additions & 7 deletions test/uploading/ghpages.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ test('creates package.json file', () => {
});

test('contain correct uploading packages', () => {
assert.fileContent('package.json', '"gulp-gh-pages": "^0.5.2"');
assert.JSONFileContent('package.json', { // eslint-disable-line
devDependencies: {
'gulp-gh-pages': '^0.5.2'
}
});
});

test('does not contain wrong uploading packages', () => {
[
'"gulp-awspublish"',
'"concurrent-transform"',
'"gulp-rsync"'
].forEach(pack => {
assert.noFileContent('package.json', pack);
assert.noJSONFileContent('package.json', {
devDependencies: {
'gulp-awspublish': '^3.0.1',
'concurrent-transform': '^1.0.0',
'gulp-rsync': '^0.0.5'
}
});
});

Expand Down
14 changes: 7 additions & 7 deletions test/uploading/no-uploading.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ test('does not create credentials files', () => {
});

test('does not contain uploading packages', () => {
[
'"gulp-awspublish"',
'"concurrent-transform"',
'"gulp-rsync"',
'"gulp-gh-pages"'
].forEach(pack => {
assert.noFileContent('package.json', pack);
assert.noJSONFileContent('package.json', {
devDependencies: {
'gulp-awspublish': '^3.0.1',
'concurrent-transform': '^1.0.0',
'gulp-rsync': '^0.0.5',
'gulp-gh-pages': '^0.5.2'
}
});
});

Expand Down
18 changes: 11 additions & 7 deletions test/uploading/rsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ test('creates package.json file', () => {
});

test('contain correct uploading packages', () => {
assert.fileContent('package.json', '"gulp-rsync": "^0.0.5"');
assert.JSONFileContent('package.json', {
devDependencies: {
'gulp-rsync': '^0.0.5'
}
});
});

test('does not contain wrong uploading packages', () => {
[
'"gulp-awspublish"',
'"concurrent-transform"',
'"gulp-gh-pages"'
].forEach(pack => {
assert.noFileContent('package.json', pack);
assert.noJSONFileContent('package.json', {
devDependencies: {
'gulp-awspublish': '^3.0.1',
'concurrent-transform': '^1.0.0',
'gulp-gh-pages': '^0.5.2'
}
});
});

Expand Down

0 comments on commit 19ea966

Please sign in to comment.