Skip to content

Commit

Permalink
update generator to 0.17.0 and testing
Browse files Browse the repository at this point in the history
Only includes some testing updates
  • Loading branch information
eddiemonge committed May 26, 2014
1 parent 63b821f commit 3c0360b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 67 deletions.
14 changes: 5 additions & 9 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict';
var util = require('util');
var path = require('path');
var spawn = require('child_process').spawn;

var join = require('path').join;
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');


Expand Down Expand Up @@ -33,14 +31,14 @@ var AppGenerator = module.exports = function Appgenerator(args, options) {
this.pkg = require('../package.json');
};

util.inherits(AppGenerator, yeoman.generators.Base);
require('util').inherits(AppGenerator, yeoman.generators.Base);

AppGenerator.prototype.askFor = function askFor() {
var cb = this.async();

// welcome message
if (!this.options['skip-welcome-message']) {
this.log(yosay());
this.log(require('yosay')());
this.log(chalk.magenta(
'Out of the box I include HTML5 Boilerplate, jQuery, and a ' +
'Gruntfile.js to build your app.'
Expand Down Expand Up @@ -133,9 +131,7 @@ AppGenerator.prototype.mainStylesheet = function mainStylesheet() {

AppGenerator.prototype.writeIndex = function writeIndex() {

this.indexFile = this.readFileAsString(
path.join(this.sourceRoot(), 'index.html')
);
this.indexFile = this.readFileAsString(join(this.sourceRoot(), 'index.html'));
this.indexFile = this.engine(this.indexFile, this);

// wire Bootstrap plugins
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"grunt"
],
"dependencies": {
"yeoman-generator": "~0.16.0",
"cheerio": "~0.13.0",
"chalk": "~0.4.0",
"yosay": "^0.1.0"
"yeoman-generator": "^0.17.0",
"cheerio": "^0.16.0",
"chalk": "^0.4.0",
"yosay": "^0.2.0"
},
"peerDependencies": {
"yo": ">=1.0.0",
Expand Down
83 changes: 29 additions & 54 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
/*global describe, beforeEach, it*/

var path = require('path');
var path = require('path');
var assert = require('assert');
var helpers = require('yeoman-generator').test;

describe('Webapp generator test', function () {
var expectedContent = [
['bower.json', /"name": "temp"/],
['package.json', /"name": "temp"/]
];
var expected = [
'Gruntfile.js',
'app/404.html',
'app/favicon.ico',
'app/robots.txt',
'app/index.html',
'app/styles/main.scss'
];

beforeEach(function (done) {
helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
if (err) {
Expand All @@ -15,8 +29,11 @@ describe('Webapp generator test', function () {
helpers.createDummyGenerator(),
'mocha:app'
]
]);
this.webapp.options['skip-install'] = true;
], null, {
'skip-install': true,
'skip-welcome-message': true,
'skip-message': true
});

done();
}.bind(this));
Expand All @@ -27,73 +44,31 @@ describe('Webapp generator test', function () {
this.app = require('../app');
});

it('creates expected files', function (done) {
var expected = [
['bower.json', /"name": "temp"/],
['package.json', /"name": "temp"/],
['Gruntfile.js', /coffee:/],
'app/404.html',
'app/favicon.ico',
'app/robots.txt',
'app/index.html',
'app/scripts/main.coffee',
'app/styles/main.scss'
];

it('creates expected CoffeeScript files', function (done) {
helpers.mockPrompt(this.webapp, {
features: ['includeSass']
});

this.webapp.coffee = true;
this.webapp.run({}, function () {
helpers.assertFiles(expected);
helpers.assertFile([].concat(expected, ['app/scripts/main.coffee']));
assert.fileContent([].concat(
expectedContent,
[['Gruntfile.js', /coffee/]]
));
done();
});
});

it('creates expected files in non-AMD non-coffee mode', function (done) {
var expected = [
['bower.json', /"name": "temp"/],
['package.json', /"name": "temp"/],
'Gruntfile.js',
'app/404.html',
'app/favicon.ico',
'app/robots.txt',
'app/index.html',
'app/scripts/main.js',
'app/styles/main.scss'
];

it('creates expected files in non-coffee mode', function (done) {
helpers.mockPrompt(this.webapp, {
features: ['includeSass']
});

this.webapp.coffee = false;
this.webapp.run({}, function () {
helpers.assertFiles(expected);
done();
});
});

it('creates expected files in AMD mode', function (done) {
var expected = [
['bower.json', /"name": "temp"/],
['package.json', /"name": "temp"/],
'Gruntfile.js',
'app/404.html',
'app/favicon.ico',
'app/robots.txt',
'app/index.html',
'app/scripts/main.js',
'app/styles/main.scss'
];

helpers.mockPrompt(this.webapp, {
features: ['includeSass']
});

this.webapp.run({}, function () {
helpers.assertFiles(expected);
helpers.assertFile([].concat(expected, ['app/scripts/main.js']));
assert.noFileContent('Gruntfile.js', /coffee/);
done();
});
});
Expand Down

0 comments on commit 3c0360b

Please sign in to comment.