Skip to content

Commit

Permalink
Updated all the tests and fixed the deploy task
Browse files Browse the repository at this point in the history
Added a bunch more tests that checks for the gulpfile tasks, that the
correct packages are installed in the package.json file and removed the
test-util.js file as it's no longer needed.

Also fixed the gulpfile always containing a deploy task even when you
selected that you didn't use it and added tests that checks for it.
  • Loading branch information
sondr3 committed Feb 4, 2015
1 parent caf91fc commit d577a8b
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 148 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ previously installed nothing will change, this is just an informal update.
* **Feed:** Updated the feed to be more up to par and completely valid
* **Packages:** Updated the packages to be more up to date on NPM

#### Behind the scenes
* **Tests:** Continued working on tests to make errors even less likely. Yay
tests.

<a name="0.7.1"></a>
## 0.7.1 - Bugfix

Expand Down
1 change: 1 addition & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ module.exports = yeoman.generators.Base.extend({
this.amazonCloudfrontS3 = hasFeature("amazonCloudfrontS3");
this.rsync = hasFeature("rsync");
this.githubPages = hasFeature("githubPages");
this.noUpload = hasFeature("noUpload");

this.amazonKey = props.amazonKey;
this.amazonSecret = props.amazonSecret;
Expand Down
4 changes: 2 additions & 2 deletions app/templates/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ gulp.task("optimize", gulp.series(
gulp.task("build", gulp.series(
gulp.series(jekyllDev),
gulp.parallel(styles, javascript, fonts, images)
));
));<% if (!noUpload) { %>

// Deploy your site for all to see
gulp.task("deploy", deploy);
gulp.task("deploy", deploy);<% } %>

// Serves your site locally
gulp.task("serve", serve);
Expand Down
37 changes: 0 additions & 37 deletions test-util.js

This file was deleted.

25 changes: 22 additions & 3 deletions test/test-creation-aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
var path = require("path");
var helpers = require("yeoman-generator").test;
var assert = require("yeoman-generator").assert;
var tasks = require("../test-util.js");

describe("Jekyllized generator test when using Amazon AWS", function () {
before(function (done) {
Expand Down Expand Up @@ -36,8 +35,28 @@ describe("Jekyllized generator test when using Amazon AWS", function () {
assert.file(expected);
});

it("should contain deploy tasks", function (done) {
tasks.assertTaskExists(this.jekyllized, "deploy", [], done);
it("should contain the correct deploy function", function () {
assert.fileContent("gulpfile.js", /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/);
});

it("should NOT contain either the GH Pages or Rsync function", function () {
assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site via Rsync to your server/);
assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site to your personal GH Pages repo/);
});

it("should contain deploy tasks", function () {
assert.fileContent("gulpfile.js", /gulp.task\(\"deploy\"/);
});

it("should contain the correct packages", function () {
var expected = [
["package.json", /\"concurrent-transform\"/],
["package.json", /\"gulp-awspublish\"/],
["package.json", /\"gulp-awspublish-router\"/],
["package.json", /\"gulp-cloudfront\"/]
];

assert.fileContent(expected);
});

});
18 changes: 15 additions & 3 deletions test/test-creation-ghpages.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
var path = require("path");
var helpers = require("yeoman-generator").test;
var assert = require("yeoman-generator").assert;
var tasks = require("../test-util.js");

describe("Jekyllized generator test when using GitHub Pages", function () {
before(function (done) {
Expand All @@ -31,8 +30,21 @@ describe("Jekyllized generator test when using GitHub Pages", function () {
assert.file(expected);
});

it("should contain deploy task", function (done) {
tasks.assertTaskExists(this.jekyllized, "deploy", [], done);
it("should contain the correct deploy function", function () {
assert.fileContent("gulpfile.js", /\/\/ Task to upload your site to your personal GH Pages repo/);
});

it("should NOT contain either the Amazon or Rsync function", function () {
assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site via Rsync to your server/);
assert.noFileContent("gulpfile.js", /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/);
});

it("should contain deploy tasks", function () {
assert.fileContent("gulpfile.js", /gulp.task\(\"deploy\"/);
});

it("should contain the correct packages", function () {
assert.fileContent("package.json", /\"gulp-gh-pages\"/);
});

});
18 changes: 15 additions & 3 deletions test/test-creation-rsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
var path = require("path");
var helpers = require("yeoman-generator").test;
var assert = require("yeoman-generator").assert;
var tasks = require("../test-util.js");

describe("Jekyllized generator test when using Rsync", function () {
before(function (done) {
Expand Down Expand Up @@ -35,8 +34,21 @@ describe("Jekyllized generator test when using Rsync", function () {
assert.file(expected);
});

it("should contain deploy task", function (done) {
tasks.assertTaskExists(this.jekyllized, "deploy", [], done);
it("should contain the correct deploy function", function () {
assert.fileContent("gulpfile.js", /\/\/ Task to upload your site via Rsync to your server/);
});

it("should NOT contain either the GH Pages or Amazon function", function () {
assert.noFileContent("gulpfile.js", /\/\/ Task to deploy your site to Amazon S3 and Cloudfront/);
assert.noFileContent("gulpfile.js", /\/\/ Task to upload your site to your personal GH Pages repo/);
});

it("should contain deploy tasks", function () {
assert.fileContent("gulpfile.js", /gulp.task\(\"deploy\"/);
});

it("should contain the correct packages", function () {
assert.fileContent("package.json", /\"gulp-rsync\"/);
});

});
51 changes: 15 additions & 36 deletions test/test-gulp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
var path = require("path");
var assert = require("assert");
var helpers = require("yeoman-generator").test;
var tasks = require("../test-util.js");

describe("Jekyllized generator test for Gulp tasks without any uploading", function () {
before(function (done) {
Expand Down Expand Up @@ -50,44 +49,24 @@ describe("Jekyllized generator test for Gulp tasks without any uploading", funct
assert.noFile(unexpected);
});

it("should contain default task", function (done) {
tasks.assertTaskExists(this.jekyllized, "default", [], done);
});

it("should contain optimize task", function (done) {
tasks.assertTaskExists(this.jekyllized, "optimize", [], done);
});

it("should contain build task", function (done) {
tasks.assertTaskExists(this.jekyllized, "build", [], done);
});

it("should contain deploy task", function (done) {
tasks.assertTaskExists(this.jekyllized, "deploy", [], done);
});

it("should contain serve task", function (done) {
tasks.assertTaskExists(this.jekyllized, "serve", [], done);
});

it("should contain clean task", function (done) {
tasks.assertTaskExists(this.jekyllized, "clean", [], done);
});

it("should contain rebuild task", function (done) {
tasks.assertTaskExists(this.jekyllized, "rebuild", [], done);
});

it("should contain styles task", function (done) {
tasks.assertTaskExists(this.jekyllized, "styles", [], done);
});
it ("should contain the standard tasks", function () {
var expected = [
["gulpfile.js", /gulp.task\(\"default\"/],
["gulpfile.js", /gulp.task\(\"optimize\"/],
["gulpfile.js", /gulp.task\(\"build\"/],
["gulpfile.js", /gulp.task\(\"serve\"/],
["gulpfile.js", /gulp.task\(\"clean\"/],
["gulpfile.js", /gulp.task\(\"rebuild\"/],
["gulpfile.js", /gulp.task\(\"styles\"/],
["gulpfile.js", /gulp.task\(\"javascript\"/],
["gulpfile.js", /gulp.task\(\"check\"/]
];

it("should contain javascript task", function (done) {
tasks.assertTaskExists(this.jekyllized, "javascript", [], done);
assert.fileContent(expected);
});

it("should contain check task", function (done) {
tasks.assertTaskExists(this.jekyllized, "check", [], done);
it("should NOT contain a deploy task", function () {
assert.noFileContent("gulpfile.js", /gulp.task\(\"deploy\"/);
});

});
100 changes: 37 additions & 63 deletions test/test-jekyll.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
var path = require("path");
var helpers = require("yeoman-generator").test;
var assert = require("yeoman-generator").assert;
var tasks = require("../test-util.js");

describe("Jekyllized generator", function () {
describe("test for Jekyll settings", function () {
Expand Down Expand Up @@ -44,64 +43,39 @@ describe("Jekyllized generator", function () {
});

it("gulpfile.js does NOT contain a deploy task", function () {
assert.noFileContent("gulpfile.js", /gulp.task \("deploy"\)/);
assert.noFileContent("gulpfile.js", /gulp.task\(\"deploy\"/);
});

it("_config.yml contains the correct title", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "title", "Mocha Test", done);
});

it("_config.yml contains the correct description", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "description", "Mocha tests for Jekyllized", done);
});

it("_config.yml contains the correct tagline", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "tagline", "Better hope this doesn\"t blow up", done);
});

it("_config.yml contains the correct author name", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "name", "Ola Nordmann", done);
});

it("_config.yml contains the correct author email", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "email", "ola.nordmann@email.com", done);
});

it("_config.yml contains the correct author bio", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "bio", "Just your average Norwegian", done);
});

it("_config.yml contains the correct author Twitter", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "twitter", "olanordmann123123", done);
});

it("_config.build.yml contains the corrent setting for future posts", function (done) {
tasks.assertJekyllBuildSettings(this.jekyllized, "future", "false", done);
});

it("_config.build.yml contains the corrent setting for drafts", function (done) {
tasks.assertJekyllBuildSettings(this.jekyllized, "show_drafts", "false", done);
});

it("_config.build.yml contains the corrent setting for LSI", function (done) {
tasks.assertJekyllBuildSettings(this.jekyllized, "lsi", "true", done);
});
it("_config.yml contains the correct settings", function () {
var expected = [
["_config.yml", /title\: Mocha Test/],
["_config.yml", /description\: Mocha tests for Jekyllized/],
["_config.yml", /tagline\: Better hope this doesn\"t blow up/],
["_config.yml", /name\: Ola Nordmann/],
["_config.yml", /email\: ola\.nordmann\@email\.com/],
["_config.yml", /bio\: Just your average Norwegian/],
["_config.yml", /twitter\: olanordmann123123/]
];

it("_config.build.yml contains the corrent setting for limiting posts", function (done) {
tasks.assertJekyllBuildSettings(this.jekyllized, "limit_posts", "0", done);
assert.fileContent(expected);
});

it("_config.build.yml contains the corrent setting for source dir", function (done) {
tasks.assertJekyllBuildSettings(this.jekyllized, "source", "src", done);
});
it("_config.build.yml contains the correct settings", function () {
var expected = [
["_config.build.yml", /future\: false/],
["_config.build.yml", /show_drafts\: false/],
["_config.build.yml", /lsi\: true/],
["_config.build.yml", /limit_posts\: 0/],
["_config.build.yml", /source\: src/],
["_config.build.yml", /destination\: dist/]
];

it("_config.build.yml contains the corrent setting for destination dir", function (done) {
tasks.assertJekyllBuildSettings(this.jekyllized, "destination", "dist", done);
assert.fileContent(expected);
});

});

describe("test pretty permalinks and 10 pages", function () {
describe("test with setting pretty permalinks and 10 posts per page", function () {
before(function (done) {
helpers.run(path.join(__dirname, "../app"))
.inDir(path.join(__dirname, "./temp/test-jekyll-pagination"))
Expand All @@ -114,17 +88,17 @@ describe("Jekyllized generator", function () {
.on("end", done);
});

it("_config.yml permalink setting is 'pretty'", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "permalink", "pretty", done);
it("_config.yml permalink setting is 'pretty'", function () {
assert.fileContent("_config.yml", /permalink\: pretty/);
});

it("_config.yml pagination setting is '10'", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "paginate", "10", done);
it("_config.yml pagination is '10' posts per page", function () {
assert.fileContent("_config.yml", /paginate\: 10/);
});

});

describe("test date permalinks and all pages", function () {
describe("test with setting date permalinks and all posts on the same page", function () {
before(function (done) {
helpers.run(path.join(__dirname, "../app"))
.inDir(path.join(__dirname, "./temp/test-jekyll-pagination-1"))
Expand All @@ -137,17 +111,17 @@ describe("Jekyllized generator", function () {
.on("end", done);
});

it("_config.yml permalink setting is 'date'", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "permalink", "date", done);
it("_config.yml permalink setting is 'date'", function () {
assert.fileContent("_config.yml", /permalink\: date/);
});

it("_config.yml pagination setting is 'all'", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "paginate", "all", done);
it("_config.yml pagination is 'all' posts per page", function () {
assert.fileContent("_config.yml", /paginate\: all/);
});

});

describe("test no permalinks and 1 page", function () {
describe("test with no permalinks setting and 1 post per page", function () {
before(function (done) {
helpers.run(path.join(__dirname, "../app"))
.inDir(path.join(__dirname, "./temp/test-jekyll-pagination-2"))
Expand All @@ -160,12 +134,12 @@ describe("Jekyllized generator", function () {
.on("end", done);
});

it("_config.yml permalink setting is 'none'", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "permalink", "none", done);
it("_config.yml permalink setting is 'none'", function () {
assert.fileContent("_config.yml", /permalink\: none/);
});

it("_config.yml pagination setting is '1'", function (done) {
tasks.assertJekyllSettings(this.jekyllized, "paginate", "1", done);
it("_config.yml pagination is '1' posts per page", function () {
assert.fileContent("_config.yml", /paginate\: 1/);
});

});
Expand Down
Loading

0 comments on commit d577a8b

Please sign in to comment.