Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

Commit

Permalink
Update to yeoman-generator 0.20.1 + test
Browse files Browse the repository at this point in the history
Fixes #551.
  • Loading branch information
silvenon committed Jun 27, 2015
1 parent 171827d commit 5c3a756
Show file tree
Hide file tree
Showing 17 changed files with 506 additions and 306 deletions.
354 changes: 238 additions & 116 deletions app/index.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions app/templates/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function (grunt) {
bower: {
files: ['bower.json'],
tasks: ['wiredep']
},<% if (babel) { %>
},<% if (useBabel) { %>
babel: {
files: ['<%%= config.app %>/scripts/{,*/}*.js'],
tasks: ['babel:dist']
Expand Down Expand Up @@ -164,7 +164,7 @@ module.exports = function (grunt) {
host: 'http://<%%= browserSync.test.options.host %>:<%%= browserSync.test.options.port %>'
}
}
},<% } %><% if (babel) { %>
},<% } %><% if (useBabel) { %>

// Compiles ES6 with Babel
babel: {
Expand Down Expand Up @@ -237,7 +237,7 @@ module.exports = function (grunt) {
// Automatically inject Bower components into the HTML file
wiredep: {
app: {
ignorePath: /^<%= config.app %>\/|\.\.\//,
ignorePath: /^<%%= config.app %>\/|\.\.\//,
src: ['<%%= config.app %>/index.html']<% if (includeBootstrap) { %>,<% if (includeSass) { %>
exclude: ['bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js']<% } else { %>
exclude: ['bower_components/bootstrap/dist/js/bootstrap.js']<% } } %>
Expand Down Expand Up @@ -414,16 +414,16 @@ module.exports = function (grunt) {

// Run some tasks in parallel to speed up build process
concurrent: {
server: [<% if (babel) { %>
server: [<% if (useBabel) { %>
'babel:dist',<% } %><% if (includeSass) { %>
'sass:server'<% } else { %>
'copy:styles'<% } %>
],
test: [<% if (babel) { %>
'babel'<% } %><% if (babel && !includeSass) { %>,<% } %><% if (!includeSass) { %>
test: [<% if (useBabel) { %>
'babel'<% } %><% if (useBabel && !includeSass) { %>,<% } %><% if (!includeSass) { %>
'copy:styles'<% } %>
],
dist: [<% if (babel) { %>
dist: [<% if (useBabel) { %>
'babel',<% } %><% if (includeSass) { %>
'sass',<% } else { %>
'copy:styles',<% } %>
Expand Down
28 changes: 19 additions & 9 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,32 @@
"grunt-autoprefixer": "^2.2.0",
"grunt-browser-sync": "^2.1.2",
"grunt-concurrent": "^1.0.0",
"grunt-contrib-clean": "^0.6.0",<% if (babel) { %>
"grunt-babel": "^5.0.0",<% } %>
"grunt-contrib-clean": "^0.6.0",
<% if (useBabel) { -%>
"grunt-babel": "^5.0.0",
<% } -%>
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-cssmin": "^0.12.2",
"grunt-contrib-htmlmin": "^0.4.0",
"grunt-contrib-imagemin": "^0.9.3",<% if (testFramework === 'jasmine') { %>
"grunt-contrib-jasmine": "^0.8.2",<% } %>
"grunt-contrib-imagemin": "^0.9.3",
<% if (testFramework === 'jasmine') { -%>
"grunt-contrib-jasmine": "^0.8.2",
<% } -%>
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-uglify": "^0.8.0",
"grunt-contrib-watch": "^0.6.1",<% if (testFramework === 'mocha') { %>
"grunt-mocha": "^0.4.12",<% } %><% if (includeModernizr) { %>
"grunt-modernizr": "^0.6.0",<% } %>
"grunt-contrib-watch": "^0.6.1",
<% if (testFramework === 'mocha') { -%>
"grunt-mocha": "^0.4.12",
<% } -%>
<% if (includeModernizr) { -%>
"grunt-modernizr": "^0.6.0",
<% } -%>
"grunt-newer": "^1.1.0",
"grunt-filerev": "^2.2.0",<% if (includeSass) { %>
"grunt-sass": "^1.0.0",<% } %>
"grunt-filerev": "^2.2.0",
<% if (includeSass) { -%>
"grunt-sass": "^1.0.0",
<% } -%>
"grunt-svgmin": "^2.0.1",
"grunt-usemin": "^3.0.0",
"grunt-wiredep": "^2.0.0",
Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions app/templates/gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
node_modules
dist
.tmp<% if (includeSass) { %>
.sass-cache<% } %>
.tmp
<% if (includeSass) { -%>
.sass-cache
<% } -%>
bower_components
19 changes: 16 additions & 3 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" href="/favicon.ico">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css(.) styles/vendor.css -->
<!-- build:css styles/vendor.css -->
<!-- bower:css -->
<% if (includeBootstrap && !includeSass) { %><link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"><% } %>
<% if (includeBootstrap && !includeSass) { -%>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
<% } -%>
<!-- endbower -->
<!-- endbuild -->
<!-- build:css(.tmp) styles/main.css -->
Expand Down Expand Up @@ -63,7 +65,6 @@ <h4><a href="http://getbootstrap.com/">Bootstrap</a></h4>
<div class="footer">
<p><span class="glyphicon glyphicon-heart"></span> from the Yeoman team</p>
</div>

</div>
<% } else { %>
<div class="hero-unit">
Expand All @@ -82,6 +83,18 @@ <h1>'Allo, 'Allo!</h1>
<!-- endbower -->
<!-- endbuild -->

<% if (includeBootstrap) { %>
<!-- build:js(.) scripts/plugins.js -->
<% bsPlugins.forEach(function (plugin) { -%>
<script src="<%= bsPath + plugin %>.js"></script>
<% }) -%>
<!-- endbuild -->
<% } %>

<!-- build:js(.tmp/app) scripts/main.js -->
<script src="scripts/main.js"></script>
<!-- endbuild -->

<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
Expand Down
10 changes: 7 additions & 3 deletions app/templates/main.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% if (includeBootstrap) { %>.browsehappy {
<% if (includeBootstrap) { -%>
.browsehappy {
margin: 0.2em 0;
background: #ccc;
color: #000;
Expand Down Expand Up @@ -86,7 +87,9 @@ body {
.jumbotron {
border-bottom: 0;
}
}<% } else { %>body {
}
<% } else { -%>
body {
background: #fafafa;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
color: #333;
Expand Down Expand Up @@ -114,4 +117,5 @@ body {
background: #ccc;
color: #000;
padding: 0.2em 0;
}<% } %>
}
<% } -%>
11 changes: 8 additions & 3 deletions app/templates/main.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<% if (includeBootstrap) { %>$icon-font-path: "../bower_components/bootstrap-sass-official/assets/fonts/bootstrap/";
<% if (includeBootstrap) { -%>
$icon-font-path: "../bower_components/bootstrap-sass-official/assets/fonts/bootstrap/";

// bower:scss
@import "bootstrap-sass-official/assets/stylesheets/bootstrap.scss";
// endbower
Expand Down Expand Up @@ -89,7 +91,9 @@ body {
.jumbotron {
border-bottom: 0;
}
}<% } else { %>// bower:scss
}
<% } else { -%>
// bower:scss
// endbower

body {
Expand Down Expand Up @@ -119,4 +123,5 @@ body {
background: #ccc;
color: #000;
padding: 0.2em 0;
}<% } %>
}
<% } -%>
File renamed without changes.
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
],
"dependencies": {
"chalk": "^1.0.0",
"cheerio": "^0.18.0",
"yeoman-generator": "^0.18.9",
"yosay": "^1.0.2"
"generator-jasmine": "^0.1.3",
"generator-mocha": "^0.1.8",
"mkdirp": "^0.5.1",
"wiredep": "^2.2.2",
"yeoman-generator": "^0.20.1",
"yosay": "^1.0.4"
},
"devDependencies": {
"grunt-cli": "^0.1.13",
"mocha": "*",
"underscore": "^1.6.0"
},
"peerDependencies": {
"generator-mocha": ">=0.1.0"
"underscore.string": "^3.1.1",
"yeoman-assert": "^2.0.0"
}
}
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ We have [recipes](docs/recipes) for integrating other popular technologies like

* `--test-framework=<framework>`

Defaults to `mocha`. Can be switched for another supported testing framework like `jasmine`.
Either `mocha` or `jasmine`. Defaults to `mocha`.

* `--babel`

Expand Down
22 changes: 22 additions & 0 deletions test/babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';
var path = require('path');
var helpers = require('yeoman-generator').test;
var assert = require('yeoman-assert');

describe('babel', function () {
before(function (done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(__dirname, '.tmp'))
.withOptions({'skip-install': true, babel: true})
.withPrompts({features: []})
.on('end', done);
});

it('adds Grunt plugin', function () {
assert.fileContent('package.json', 'babel');
});

it('adds Grunt task', function () {
assert.fileContent('Gruntfile.js', 'babel');
});
});
69 changes: 69 additions & 0 deletions test/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
'use strict';
var path = require('path');
var helpers = require('yeoman-generator').test;
var assert = require('yeoman-assert');

describe('bootstrap', function () {
describe('general', function () {
before(function (done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(__dirname, '.tmp'))
.withOptions({'skip-install': true})
.withPrompts({features: [
'includeBootstrap'
]})
.on('end', done);
});

it('adds Bootstrap dependency', function () {
assert.fileContent('bower.json', 'bootstrap');
});

it('doesn\'t explicitly add jQuery dependency', function () {
assert.noFileContent('bower.json', 'jquery');
});

it('adds Bootstrap paths to Gruntfile.js', function () {
assert.fileContent('Gruntfile.js', 'bootstrap');
});

it('adds HTML description', function () {
assert.fileContent('app/index.html', 'Bootstrap');
});
});

describe('with Sass', function () {
before(function (done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(__dirname, '.tmp'))
.withOptions({'skip-install': true})
.withPrompts({features: [
'includeSass',
'includeBootstrap'
]})
.on('end', done);
});

it('uses Bootstrap Sass', function () {
assert.fileContent('bower.json', '"bootstrap-sass-official"');
assert.fileContent('Gruntfile.js', '/bootstrap-sass-official/');
});
});

describe('without Sass', function () {
before(function (done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(__dirname, '.tmp'))
.withOptions({'skip-install': true})
.withPrompts({features: [
'includeBootstrap'
]})
.on('end', done);
});

it('uses regular Bootstrap', function () {
assert.fileContent('bower.json', '"bootstrap"');
assert.fileContent('Gruntfile.js', '/bootstrap/');
});
});
});
38 changes: 38 additions & 0 deletions test/general.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';
var path = require('path');
var helpers = require('yeoman-generator').test;
var assert = require('yeoman-assert');

describe('general', function () {
before(function (done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(__dirname, '.tmp'))
.withOptions({'skip-install': true})
.withPrompts({features: []})
.on('end', done);
});

// not testing the actual run of generators yet
it('can be required without throwing', function () {
this.app = require('../app');
});

it('creates expected files', function () {
assert.file([
'package.json',
'bower.json',
'.bowerrc',
'Gruntfile.js',
'app/favicon.ico',
'app/index.html',
'app/scripts/main.js',
'app/styles/main.css',
'app/robots.txt',
'test',
'.jshintrc',
'.editorconfig',
'.gitignore',
'.gitattributes'
]);
});
});
32 changes: 32 additions & 0 deletions test/modernizr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';
var path = require('path');
var helpers = require('yeoman-generator').test;
var assert = require('yeoman-assert');

describe('modernizr', function () {
before(function (done) {
helpers.run(path.join(__dirname, '../app'))
.inDir(path.join(__dirname, '.tmp'))
.withOptions({'skip-install': true})
.withPrompts({features: [
'includeModernizr'
]})
.on('end', done);
});

it('adds Bower dependency', function () {
assert.fileContent('bower.json', 'modernizr');
});

it('adds Grunt plugin', function () {
assert.fileContent('package.json', 'modernizr');
});

it('adds Grunt task', function () {
assert.fileContent('Gruntfile.js', 'modernizr');
});

it('adds HTML description', function () {
assert.fileContent('app/index.html', 'Modernizr');
});
});

0 comments on commit 5c3a756

Please sign in to comment.